Re: -Tunes - Overcoming File Permission Error -54
Re: -Tunes - Overcoming File Permission Error -54
- Subject: Re: -Tunes - Overcoming File Permission Error -54
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 05 Apr 2007 10:34:05 -0700
- Thread-topic: -Tunes - Overcoming File Permission Error -54
Title: Re: -Tunes - Overcoming File Permission Error -54
> I'm new to AppleScript.
>
> I recently needed a script for adding an album of audio files and
> associated tags to iTunes.
Welcome aboard, I'd say you're off to a pretty good start.
> The first version (using a single loop) can cause an "Applescript
> Error: iTunes got an error: File Permission Error -54." to occur.
--Here's what I've used in similar situations
set itemsNotPRocessed to {}
repeat with thiItem in myList
try
DoSomeStuff(thisItem as item)
on error
set the end of itemsNotPRocessed to thisItem
end try
end repeat
repeat with thisItem in itemsNotPRocessed
DoSomeStuff(thisItem as item)
end repeat
--For your script it could work something like this:
on export_to_iTunes(albumTitle, albumArtist, albumGenre, albumYear, tracklists)
-- tracklists is an array of {title, artist, fileRef}
repeat with trackNumber from 1 to count of tracklists by 1
set thisTrack to item trackNumber of tracklists
try
exportThiTrack(albumTitle, albumArtist, albumGenre, albumYear, thisTrack, trackNumber)
on error
set the end of itemsToReTry to {thisTrack, trackNumber}
end try
end repeat
repeat with x from 1 to the count of itemsToReTry
try
set {thisTrack, trackNumber} to item x of itemsToReTry
exportThisTrack(albumTitle, albumArtist, albumGenre, albumYear, thisTrack, trackNumber)
on error
--you could keep trying or give up after it fails twice.
end try
end repeat
end export_to_iTunes
on exportThisTrack(albumTitle, albumArtist, albumGenre, albumYear, thisTrack, trackNumber)
tell application "iTunes"
set trackName to item 1 of thisTrack as string
set trackArtist to item 2 of thisTrack as string
set fileRef to item 3 of thisTrack as POSIX file
set trackRef to add fileRef to playlist 1
set album of trackRef to albumTitle
set album artist of trackRef to albumArtist
set genre of trackRef to albumGenre
set year of trackRef to (albumYear as number)
set name of trackRef to trackName
set artist of trackRef to trackArtist
set track count of trackRef to count of tracklists
set track number of trackRef to trackNumber
end tell
end exportThisTrack
HTH,
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden