Deleting all songs in a given iTunes playlist using Applescript I'm working on a script to manage my "queue" playlist in iTunes and wanted an easy and fast way to quickly delete all songs in that playlist.

Applescript seemed the best option and I created a little script executable with a keyboard shortcut. However it doesn't seem to work.

This is the relevant part:

tell application "iTunes"
    repeat with t in tracks of playlist "queue"
        tell playlist "queue" to delete t
    end repeat
end tell


The problem is that not all the tracks are deleted, only a part of them. Executing the script multiple times, eventually, deletes all the tracks in the playlist.
I've had the exact same problem. There's more and more AppleScript bugs in each version of OS X.

If you just want to delete all tracks on a playlist, single expressions like this don't seem to skip any tracks and they're also faster:

tell application "iTunes"
    delete tracks of playlist "untitled playlist"
end tell


If you only need to delete some tracks, something like this might work:

tell application "iTunes"
    repeat
        set tr to tracks of playlist "untitled playlist"
        if tr is {} then exit repeat
        repeat with t in tr
            delete t
        end repeat
    end repeat
end tell