How To: Batch Copy Music From iTunes to Another Directory
I found myself having to figure out how to do this the other day, so i decided to tackle the problem. I also didn’t want to install any extra software (I am sure there are some apps that will do this for you). The solution is not very difficult, but it does require perl to be installed (yes i know, i said didn’t want to install anything extra, but perl was already installed). The benefit of a perl solution is that it will be easy to convert the perl script to a cgi script that can be used on a web page (i.e. you just go to a web page of mine and it does the magic for you).
The steps to make this happen are the following:
- Make a new playlist in iTunes (call it whatever you want)
- Add all the songs you want to batch copy to this new playlist (this can be very fast as you can use the built in filtering in iTunes to batch add files to the playlist)
- Export the playlist to your computer (just put it on the desktop or something)
- then run the script: perl convert.pl myPlaylist.txt ucs-2le > myPlaylist.bat
So obviously, you will need to run this in a console window, and you will need to have both the convert.pl and the myPlaylist.txt (or whatever you name it) in the current directory. I recommend making a new folder (copied-mp3 or something like that) and then dump those two files into it, then navigate to it in the console. The ucs-2le is the character encoding format, this is the value you would use for windows iTunes. I am not sure what to use for Mac, it depends on what mac iTunes exports playlists to. You can always convert the playlist txt file to ASCII encoding and then use ascii instead.
The command will build a batch file (myPlaylist.bat in the example above) as it runs. It shouldn’t take long to run, like a couple of seconds unless you have billions of mp3’s in the playlist. All you have to do is run the batch file (double click or through the console window) and all of your songs in the playlist will be automagically copied to the current directory (wherever you are running the batch file from).
Grab the script HERE (convert.pl) – Make sure you save this as convert.pl and not as convertpl.txt
If there is interest in this script, i will definitely make a web site for it. Otherwise I will just leave it here for people to use at their own leisure. If YOU feel like turning this script into a web site, feel free, but please let me know before you do so I can clean up the script a little first (and please link to this site).
2 Comments
Thanks for this helpful post. I was looking for something like this :)
Great script. Just what I needed. I have all my music in iTunes and I have a couple iPods. But, I’ve also got a couple of new Android phones that I’m testing and I’m looking for ways to put my iTunes playlists on the phones. I modded the script a bit to suit my needs, but this is perfect.
BTW, point out in step #3, you need to export the playlist as .txt and not .xml.
-E