PDA

View Full Version : Delete Song from iTunes


Jay Carr
07-01-2010, 03:36 AM
I'm trying to create an automator action that runs a script that deletes a specific song from the iTunes library (not just the file, but the XML reference in the iTunes lib as well.)

Basically, this is for an Automator Workflow "Folder Action" that allows me to export a 35 second clip from Ableton Live (music creation software) into a specific folder (called Ringtones) and then have that song turned into a ringtone and put into my iTunes library.

The Automation so far:

Step 1: Import Audio Files -- It takes the file out of the folder and converts it to .aac, importing it into the iTunes library at the same time.

Step 2: Copy Finder Items -- Puts the .m4a back into my desktop folder called Ringtones.

Step 3: Replace Text in Finder Item Names -- I use this to replace .m4a with .m4r so that I now have a ringtone.

Step 4: Applescript -- I need this script to remove the .m4a from the iTunes library. If it's not removed, the putting then importing the .m4r will not work, it simply recognizes it as the .m4a from before and doesn't add it to ringtones. If I delete the .m4a from the library manually, I can then import the .m4r as a ringtone, I just want it automated you see...

Step 5: Import Files into iTunes -- Puts the .m4r into iTunes (I think, haven't really gotten to this step yet...)

Any and all help is welcome, including a change in strategy if it is needed (ie., going all Applescript and all).

As a warning -- my understanding of AppleScript is rudimentary at best. But I'm willing to learn. That being said, I would appreciate it if someone simply gave me the script...

renaultssoftware
07-01-2010, 04:03 AM
I'm sure you can use the delete <track> command to do that. Experiment with that and report back.

Jay Carr
07-01-2010, 08:44 AM
I've taken a look at using a script that uses that command. The difficulty for me is figuring out how to indicate what <track> is.

When Automator gives me the space to create the Apple Script it gives me two variables. Input & Parameters. Input apparently is a list that includes any input I've given the automator action so far. Trouble is, I have no idea how to pull info out of that list and print it off, so I can see what it is. In Java, I'd just use a for loop, find the relevant data, and then proceed to have it deleted. But I don't know if you can do that in Javascript (and my internet searches haven't turned much up for me...)

chabig
07-01-2010, 07:00 PM
Go check out Doug's Applescripts for iTunes (http://dougscripts.com/itunes/). You'll probably find what you want already written. If not, you can study those scripts to find your answer.

renaultssoftware
07-04-2010, 12:32 AM
How about:
delete track "Song" of playlist "Playlist"