i2aCleaner—Perl Script to Remove Unused Music from Android microSD Card

One problem with using the itunes2android Perl script to create playlists and populate your Android microSD card for use with the Just Playlists app is that it’s a bit hard to remove music selectively in the future.  For instance, if you have several playlists that you created using itunes2android and then decide you’d like to remove one of the playlists and the music that it references, you’d have to go through the music directory and delete the directories and music files manually.  Even worse, if you delete music that is still referenced in another playlist, that playlist won’t be able to find it.

I wrote the i2aCleaner script to get around this problem.  If you want to remove the music associated with a playlist, just delete the playlist out of your \Music\Playlists directory on your microSD card and then, while it’s mounted under Windows, run i2aCleaner.  This script looks at all your playlist files and removes any music from under the music directory created by itunes2android that isn’t referenced in any playlist.  In my case and in the example I used when describing itunes2android, this is the D:\Music\ipod directory when your microSD card is mounted.  Again referring to the original example and assuming you put the i2aCleaner script in C:\scripts on your computer, the command line to do this would be

perl c:\scripts\i2acleaner.pl d ipod

where “d” is the drive letter of your mounted phone or microSD card and “ipod” is the name of the directory where your music is stored under \Music on the microSD card.

The script will get rid of all unused music and directories.  It won’t affect anything else in your D:\Music directory.

Remember that this script will only work right if you use the itunes2android script to manage your playlists.  And if you have music that you moved over to the microSD card in some other way, it shouldn’t be kept under the \Music\ipod directory, since it will get deleted by i2aCleaner if not referenced by the playlist files.

You can download a ZIP archive with the i2aCleaner script here.

Comments are closed.