Delete Unwanted Mp3s Not in Your iTunes Library

February 12th, 2009

itunesdelete.pngI listen to a lot of new music every week, and as a result, I end up deleting a lot of music after listening to it once or twice. The problem I’ve run into is that when I’m trying to delete a song from my music library, iTunes, as a precaution, gives me the dialogue box on the right.

Now this isn’t a problem in and of itself, but for some reason, I tend to simply press return when I see this box, instead of pressing the “Move to Trash” button. Pressing return selects the “Keep File” button, which means that somewhere in my iTunes folder, I’ll have an mp3 laying around which I a) don’t want and b) forget about. This might not seem like a big deal, but as it turned out, I have over 1.5GB of these kinds of files, just wasting space on my MacBook Pro.

Today I realized that I must not be the only one with this problem, and so a routine Google search revealed that there was indeed a simple solution. There is an AppleScript called List Music Folder Files Not Added that will search a specified folder (in my case my iTunes Music folder) for any files which are not in your iTunes Music Library.

Two important notes before we go on:

  • If you, for any reason, think you removed songs/videos/podcasts/etc from iTunes but intentionally clicked Keep File in the dialogue box above, do NOT follow these instructions because your media will be erased.
  • This tip will only work if you have the following checkboxes checked in your iTunes Preferences–> Advanced: ‘Keep iTunes Music folder organized’ and ‘Copy files to iTunes Music folder when adding to library.’ I highly recommend both of these settings be enabled anyway, especially since you can simply consolidate your library.

Here’s all you have to do:

  1. Download the List Music Folder Files Not Added script from Doug’s AppleScripts for iTunes (a very useful site).
  2. Double click on the DMG to mount it and then copy the “CocoaCallBridge” and “List Music Folder Files Not Added” files to the following folder: [your username]/Library/iTunes/Scripts. I you don’t have a Scripts folder in iTunes, just create one.
  3. Open iTunes and you should see a little black script icon in the menubar next to Window. Click on it and select the List Music Folder Files Not Added script.
  4. It will open the AppleScript and ask you which folder you want to compare to your iTunes Music Library. For my problem, I selected all of the folders (cmd+a) within /Users/[your username]/Music/iTunes/iTunes Music. Then press return.
  5. It then gives you another dialogue box which asks where you want to save the exported file. I simply chose my Desktop so that it would be easy to find. Be sure to fill in the box where it says “Save As:” with a filename that ends in m3u. This will create a playlist of all of the songs you removed from the iTunes library but didnt delete. Press return and let it do its work (might take a while depending on the size of your library). If you’re running Leopard it might warn you about running the CocoaCallBridge application – just say yes and let it do its work – its part of the AppleScript).
  6. When the AppleScript tells you that it finished, go to iTunes and create a new playlist. Then drag the m3u file that the AppleScript created into that playlist.
  7. Now in one swoop, select all of the songs in that playlist (cmd+a), and press cmd+option+delete. It will now give you that dialogue box you see at the top of this post. BE SURE TO CLICK MOVE TO TRASH (if you press return, you’re gonna have to repeat step 6 again). Now the unwanted mp3s are in your trash. Before emptying your trash, take a look just in case at what you just erased one last time.

That’s all you have to do! It’s a great little script and it saved me over 1.5GB on my hard drive! If you have any questions, leave me a comment and I’ll clarify anything you need. Enjoy.

my writing

my website is a collection of my work and writing since 2004, so please don't be surprised if things seem a little outdated, particularly in the technology section. That said, the concepts behind most posts should be interesting given all that's happened since they were written so enjoy!