10.5 to 10.6 breaks script?

I have a script that worked perfectly in 10.4 and 10.5, but not in 10.6. I called Apple and they were not able to give any advice as to how to go about fixing this. Any ideas?


tell application "iTunes"
   activate
   if kind of container of view of front browser window is not library or selection of front browser window is {} then
       display dialog "You must select some tracks first." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
   end if
   
   
   set sel to selection of front browser window
   -- plural for dialog
   set s to "s"
   if (count of items in sel) is 1 then set s to ""
   
   set myEncoders to name of every encoder
   set encoderBackup to name of current encoder
   
   set myNewEncoder to (choose from list myEncoders with prompt ¬
       "Convert track" & s & " using..." default items (encoderBackup as list) ¬
       OK button name "OK" cancel button name ¬
       "Cancel" without multiple selections allowed and empty selection allowed) as string
   if myNewEncoder is "false" then error number -128
   
   set uD to (choose folder with prompt "Move converted file" & s & " to...")
   if uD is false then error number -128
   
   set current encoder to encoder myNewEncoder
   set pathToImage to "Mac HD:Users:Studio:Documents:Album Art:AlbumArt.pct"
   set currentArtwork to (read file pathToImage from 513 as artwork)
   
   set cnt to 0
   repeat with this_track in sel
       try -- skip on failure
           if cnt < 9 then
               set zeroStr to "0" & (cnt + 1) as string
           else
               set zeroStr to (cnt + 1) as string
           end if
           set new_track to item 1 of (convert this_track)
           set loc to new_track's location
           set dbid to new_track's database ID
           set name_hold to zeroStr & "-" & (get name of new_track) & "-companyname"
           set name of new_track to name_hold
           -- change ID3 tags
           set artist of new_track to "Company Name"
           set album of new_track to "[url=http://www.companyname.com]www.companyname.com[/url]"
           set rating of new_track to 0
           set grouping of new_track to ""
           set composer of new_track to ""
           set comment of new_track to ""
           set track number of new_track to 0
           set track count of new_track to 0
           set disc number of new_track to 0
           set disc count of new_track to 0
           set data of artwork 1 of new_track to currentArtwork
           
           -- move the file to new location
           do shell script "mv " & (quoted form of POSIX path of loc) & " " & (quoted form of POSIX path of uD as string)
           
           -- delete the track
           delete new_track
           set cnt to cnt + 1
       end try
       
   end repeat
   
   set current encoder to encoder encoderBackup
   display dialog "Done." buttons {"Thanks"} default button 1 with icon 1 giving up after 90
   
end tell

The script:

  1. no longer saves in the location specified, but now creates a folder named whatever the value “album” is set to, within a folder named whatever the value “artist” is set to,
  2. does not increase cnt by one, so all files are prefixed by “01-”
  3. does not delete the converted track

Any help would be GREATLY appreciated. Thanks.

Hi,

the reason for 2) and 3) is probably an error within the try block.
When an error occurs the code until the end try line will be skipped,
the counter won’t be incremented and the file won’t be deleted

For debugging comment out any try block to get errors or catch the errors with an on error branch

Thank you, Stefan. The problem turned out to be:

set data of artwork 1 of new_track to currentArtwork

Not sure why. This worked before.