TL;DR; A way of exporting iTunes playlists with relative paths is described here.
iTunes Export
Once upon a time I wrote a little tool for exporting playlists from Songbird/Nightinale. After migrating to iTunes, I was looking for a tool that provides the same functionality for iTunes. Fortunately, there already is one: iTunes Export. It’s twofold – you can either use a UI or a console version. I’m more the console type of guy, so my choice is clear. The latest release, version 2.2.2, was released in 2010, almost 5 years ago… and it still works with iTunes 12.1.2 – it’s a miracle! And it’s fast – my approximately 100 playlists are exported in less than 2 minutes.
Relative Playlist workaround
Among all those parameters of iTunes export, there is none for creating relative playlists, though. However, we can use a workaround for achieving this, by combining the musicPath
and musicPathOld
parameters. Here’s what the doc says:
musicPath
iTunes Export will use the absolute location of your music files in the playlist. iTunes Export accepts a command line parameter that will override this default. Example:java -jar itunesexport.jar -musicPath="c:\My Music Directory"
musicPathOld
Tunes Export will only apply the prefix to tracks stored in the directory configured in iTunes as the iTunes Music Folder location. Files stored in a different directory will not have the prefix applied.If you only wish to override a portion of the music path you can specifi the musicPathOld parameter. iTunes Export will replace this path with the musicPath parameter instead of replacing the default music path.java -jar itunesexport.jar -musicPathOld="c:\My Old Path"
A bit complicated, eh?!
Exporting playlists with relative paths by example
I’ll point out how we can use those parameters by a small example. Imagine the following folder structure
D:\Music\ Playlists\ Artist1\ Song1.ext Artist2\ Album\ Song2.ext iTunes iTunes Library.xml
If we had a playlist call playlistX
that contained Song1
and Song2
(anyone remember a band called Blur? 🙂 ) and we would export it without further parameters to the Playlists
folder, it would look like this:
D:\Music\Artist1\Song1.ext D:\Music\Artist2\Album\Song2.ext
What we’re going to do is replace the absolute part with a relative one (in respect to the destination folder for playlists). In our example: Replace “D:\Music
” by “..
” because it’s the parent folder of “D:\Music\Playlists
“. That’s exactly what the parameters mentioned above are for! musicPathOld
is the the part that is going to be replaced by musicPath
. Speaking of which, our call to iTunesExport looks like this:
java -jar itunesexport.jar -library="D:\Music\iTunes\iTunes Library.xml" -outputDir="D:\Music\Playlists" -musicPath=".." -musicPathOld="D:\Music"
and results in the file D:\Music\Playlists\playlistX.m3u
..\Artist1\Song1.ext ..\Artist2\Album\Song2.ext