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