iTunes Script issue (Not directly indigo related!)
Posted: Fri Jun 08, 2018 5:17 pm
So I’ve had this AppleScript in my library for years and it’s very handy.. it actually randomly re-orders a playlist rather than just the live shuffle that iTunes does. I found it very handy back in the day but I’ve not used it for years because I kinda just forgot it existed.. but on having rediscovered it and thinking that’d actually be really useful I find that it doesn’t work anymore. Anyone have any ideas on modifying it to work with current versions of iTunes? My hope is I can get it working again and then get indigo to execute it every night to randomise some of my playlists that I use regularly (which I believe isn’t being affected by Indigo’s depreciation of AS as it’s an external script.. have I got that right?). Or indeed has anyone got a more efficient way of getting iTunes to actually re-order the playlist rather than just toggle on shuffle?
The script:
And the error:
The script:
- Code: Select all
tell application "iTunes"
activate
beep
set thePlaylist to (get view of front window)
set trackCount to (get index of last track of thePlaylist)
set newList to {}
repeat with i from 1 to trackCount
set newList to newList & (get location of track i of thePlaylist)
end repeat
repeat with i from length of newList to 1 by -1
set current_item to (random number from 1 to i)
tell newList
set temp to item i
set item i to item current_item
set item current_item to temp
end tell
end repeat
set oldPlaylist to (get name of thePlaylist as string)
delete thePlaylist
set ranPlaylist to (make new user playlist)
set name of ranPlaylist to oldPlaylist
repeat with i from 1 to (get count of newList)
try
add item i of newList to ranPlaylist
end try
end repeat
beep
display dialog "The playlist " & (get name of ranPlaylist as string) & " with " & trackCount & " tracks was randomized."
end tell
And the error:
- Code: Select all
error "iTunes got an error: Can’t get location of track 1 of user playlist id 83267 of source id 67." number -1728 from location of track 1 of user playlist id 83267 of source id 67