baltal
08-09-2003, 12:32 PM
The script was painfully slow for a long playlist and large library. Looking at the code, I suspected this was due to matching track names (applescript is pretty slow for string searches) and continuing through the entire library after finding a track.
I replaced the core loop with the following code. It uses track duration, an integer variable, as the first "search" criterion. The boolean-and for track and album names further qualify, after which I take a leap of faith that there are no other tracks worth looking for. Seems to work pretty well and gets about a 4x speed increase, though ymmv, as the saying goes.
repeat with i from 1 to the count of tracks in Podlist
set trName to the name of track i of Podlist
set trAlbum to the album of track i of Podlist
set trDuration to the duration of track i of Podlist
set theTrack to (the first track in playlist "Library" of source "Library" whose ((duration is trDuration) and (name is trName) and (album is trAlbum)))
duplicate theTrack to iTunesList
end repeat
baltal
I replaced the core loop with the following code. It uses track duration, an integer variable, as the first "search" criterion. The boolean-and for track and album names further qualify, after which I take a leap of faith that there are no other tracks worth looking for. Seems to work pretty well and gets about a 4x speed increase, though ymmv, as the saying goes.
repeat with i from 1 to the count of tracks in Podlist
set trName to the name of track i of Podlist
set trAlbum to the album of track i of Podlist
set trDuration to the duration of track i of Podlist
set theTrack to (the first track in playlist "Library" of source "Library" whose ((duration is trDuration) and (name is trName) and (album is trAlbum)))
duplicate theTrack to iTunesList
end repeat
baltal