Applescript to delete track from itunes

Hi,

This seems like a easy question but I can't get it to work. I needed to delete tracks on iTunes with applescript. But something like the following script gives me the error that itunes does not understand the delete message.

tell application "iTunes"
set myTrack to track "deleteme" in the playlist "Audiobooks"
delete myTrack
end tell

The error reads: iTunes got an error: file track id 13543 of user playlist id 9599 of source id 41 doesn't understand the delete message.

Ideas? I'm using the latest version of iTunes.

Cheers

Macbook Pro, Mac OS X (10.4.6)

Posted on Jan 14, 2007 5:06 AM

Reply
2 replies

Jan 14, 2007 12:49 PM in response to PT

Cheers man, had a look around and found a solution. Basically delete the track by using it's database ID as assigned in iTunes.

tell application "iTunes"
set myTrack to track "deleteme" in the playlist "Audiobooks"
set dbid to myTrack's database ID
delete (some track of library playlist 1 whose database ID is dbid)
end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript to delete track from itunes

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.