• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
iTunes - Overcoming File Permission Error -54
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iTunes - Overcoming File Permission Error -54


  • Subject: iTunes - Overcoming File Permission Error -54
  • From: Citizen <email@hidden>
  • Date: Thu, 5 Apr 2007 10:48:04 +0100

Hello,

I'm new to AppleScript.

I recently needed a script for adding an album of audio files and associated tags to iTunes.
The first version (using a single loop) can cause an "Applescript Error: iTunes got an error: File Permission Error -54." to occur. Which as I understand it, is a file open error - caused because my program is attempting to add the tags while iTunes is still processing one of the newly inserted audio files.

This is the listing for version one:
------
on export_to_iTunes(albumTitle, albumArtist, albumGenre, albumYear, tracklists)
-- tracklists is an array of {title, artist, fileRef}

tell application "iTunes"
repeat with trackNumber from 1 to count of tracklists by 1
set thisTrack to item trackNumber of tracklists
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 repeat
end tell
end export_to_iTunes
------ 

I managed to resolve this by dividing the addition of the audio files and the tags into two separate loops to create version two:

------
on export_to_iTunes(albumTitle, albumArtist, albumGenre, albumYear, tracklists)
-- tracklists is an array of {title, artist, fileRef}


tell application "iTunes"
set trackRefList to {}
repeat with trackNumber from 1 to count of tracklists by 1
set thisTrack to item trackNumber of tracklists
set fileRef to item 3 of thisTrack as POSIX file
set end of trackRefList to add fileRef to playlist 1
end repeat
repeat with trackNumber from 1 to count of tracklists by 1
set trackRef to item trackNumber of trackRefList
set thisTrack to item trackNumber of tracklists
set trackName to item 1 of thisTrack as string
set trackArtist to item 2 of thisTrack as string
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 repeat
end tell
end export_to_iTunes
------

Now this second version seems to work without the error caused by version one, but now the audio files are added all over the iTunes library first - and then organised into one album as the tags are added in the second loop. Which is visually unappealing, as it gives the impression that the newly added tracks are out of order, until all the tracks have been added.

The first version is visually much more appealing (when it works) - as each audio file was added (almost immediately) to its correct album. It gave the user the visual feedback they were expecting - the tracks are added and organised in the same way as if they were ripping a CD.

So I'm after advice on how to prevent the "File Permission Error -54" from occurring in the first, single loop version.

Is there a way of checking that iTunes has finished with the audio file before adding its tags? or is there an even better way of resolving this problem?

Thanks in advance,
Dave

------
David Kennedy (http://www.zenopolis.com)


 _______________________________________________
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

  • Prev by Date: TextCommands "check" results wrong?
  • Next by Date: Re: Can not get "item" from "position"
  • Previous by thread: Re: TextCommands "check" results wrong?
  • Next by thread: Re: -Tunes - Overcoming File Permission Error -54
  • Index(es):
    • Date
    • Thread