itunes2android—Perl Script for Moving Music from iTunes to an Android microSD Card

To use the Just Playlists program on an Android phone, you need to create M3U playlists and move them and your music to your phone’s microSD card.  If you use iTunes to manage your music library on your computer—as I do—one way to accomplish this is to use the iTunes playlists as the starting point.  The Perl script I created called itunes2android does just this.  You can download it here.

The script is meant to be run under Microsoft Windows—though adapting it to the Mac or Linux wouldn’t be difficult.  Here are the steps for using it:

  • Download the script and save it to a folder on your computer—let’s call it C:\scripts as an example.  It’s in a ZIP archive, so be sure to unzip it.
  • Install a Perl interpreter on your computer.  The one I use is called Strawberry Perl and can be found here.  ActiveState makes another Perl distribution for Windows.  It should work with it, as well, though I haven’t tried it.
  • Use iTunes to create a playlist of some of your music.  Once this is done, right-click on the playlist name.  One of the choices in the menu is “Export…”.  Choose this, and choose to export it as a text file into a folder of your choice.  Let’s use C:\playlists as an example directory and favorites.txt as the playlist export file name.
  • Now, open a DOS command prompt and change directory to where you put the exported playlist.  Using my example directory, the command would be

cd c:\playlists

  • Connect your Android phone to your computer with its USB cable.  Once connected, pull down the notification bar on the phone and choose to mount your microSD card.
  • Open up “My Computer” on your computer and note the drive letter assigned to your phone.  Let’s assume it’s D:
  • Go back to your DOS command prompt window and use the itunes2android script.  Using my example set-up, the command would be

perl c:\scripts\ favorites.txt d

  • The script will run and tell you what it’s doing.  When it’s done, you can open up the microSD card on your computer and look around for the new files it copied over.  When you’re done, unmount your phone and you’ll be ready to go.

The script will create a directory tree on your microSD card of D:\Music\ipod\… for your music tracks, based on the structure you’ve used to store them on your computer.  The “ipod” directory isn’t special but just happens to be the way I do it, to keep music moved over by itunes2android separate from any other files in the “Music” folder.   The “Music” folder is probably already on your microSD card, since it’s where Android puts music by default.  There will also be a D:\Music\Playlists folder that will contain the file favorites.m3u.  This is the playlist that you can use with Just Playlists.

A few more details.  First, I choose to manage my music files manually and thus they aren’t stored in the default iTunes directory structure.  I store my music as C:\ipod\<Artist>\<Album>\<track>.  If you let iTunes decide where to keep your music, the above should still work, but I don’t know exactly what directory structure you’ll end up with on your microSD card.  Feel free to comment here and let me know what you get or if it gives you problems.  Also, I live in the USA and have all my data on a Windows computer using character sets for English.  My script might have problems if you are using character sets for other languages.

If you use iTunes to add album art to your music, it doesn’t actually put the artwork in each music file.  I manually tell iTunes to write the artwork to each music file.  This way, other music players like Just Playlists and the default Android music player can find the artwork.  I’d be glad to post on how to do this in the future, if anyone is interested.

Finally, you can use the M3U playlists you create in the default music player on your Android phone.  They will show up in the “Playlists” list, once Android gets around to re-scanning your microSD card.  Your music will also show up under the other play categories in the default music player.  I should make the disclaimer that this is true with a Google Experience phone like the G1.  I’d guess it should also be true for the music players on phones like the Hero and Droid, but I haven’t used them to be sure.

Comments are closed.