A script (with Unicode support) to zip iTunes playlists
May 25, '07 07:30:02AM • Contributed by: Anonymous
May 25, '07 07:30:02AM • Contributed by: Anonymous
This hint is useful if you want to zip many tracks of music located in your iTunes Library, belonging to different albums by different artists. For instance, you might want to use such a method to create a single backup file. Or for transferring your music to a second computer. I'll assume you have already nicely arranged the songs of interest in a playlist. You can then burn them on a CD, but can you zip them instead? You can, but one annoying problem is those pesky accents, umlauts, and other exotic characters (including the /) that plague titles and artists' names, particularly if you enjoy international music. Fortunately, iTunes uses Unicode characters, and this is one way to deal with them:
The script (a Ruby one, ideal for this task) simply manipulates the file playlist.txt to create a list of locations (separated by spaces) of all the tracks in your playlist and then archives them using this command:
- Select the playlist and export it from iTunes (on Menu » File » Export). Choose Unicode Text (rather than Plain Text) from the Format pop-up.
- Open the playlist in TextEdit, and save it in UTF-8 mode (this is crucial, because iTunes apparently exports it in UTF-16).
- Copy and paste this script into a new pure text file and save it. I called it iTunes_to_zip.rb, but feel free to use whatever name you like.
- Open Terminal. Go to the directory where you put the script. Make it executable running the command chmod a+x iTunes_to_zip.rb.
./iTunes_to_zip.rb /path/to/exported/playlist.txt name_of_archive_to_create.zip
Replace /path/to/exported/playlist.txt and name_of_archive_to_create.zip, obviously. That's it. You will have a new .zip file that contains all the tracks of your playlist.The script (a Ruby one, ideal for this task) simply manipulates the file playlist.txt to create a list of locations (separated by spaces) of all the tracks in your playlist and then archives them using this command:
zip -v name_of_archive_to_create.zip /Users/...mp3 /Users/...mp3 etc.
Two warnings:
- It should work even if the iTunes Library is on a FAT32 hard drive, but farther testing is welcome.
- zip, by default, stores the whole path with each file, so that the directory structure is preserved. If you prefer to keep all tracks in the same folder, just edit the script and simply edit the last line, replacing zip -v with zip -jv. But then, if two different tracks have the exact same name, zip will abort with a message.
•
[9,787 views]
