iPod To Computer
Get Filenames And ID3 Tags Back / Coding

Type: Music
Created: 2015.08.24
Posted: 2017.10.31

Have music on your iPod that isn't on your computer?
Good news, your music can be recovered.
Bad news, it isn't super easy.
OK news, I wrote a PHP script to make it easier.

Background

Years ago a friend asked if I could help her mom recover music stuck on her iPod. Most of it was music she ripped from owned CDs, but her computer crashed and she lost everything. To save time from ripping every CD again, my friend thought her mom's music could be transferred back to her computer from her iPod. I thought so too, and while it was easy to get the files, I ran into a problem, all ID3 tags were stripped from the files, filenames were random letters (HBUC.m4a) and files were in random folders. But the pieces to the puzzle are stored in a SQLite database.

Approach

Since all of the information is in a SQLite database, I thought to export each type of information (genre, track name, location, etc.) into a different XML file. I chose XML because XML is easy to deal with in PHP. After studying the data for a while, I found the relations and then started to piece together a PHP script.

Software

SQLite Manager - Firefox Add-on
MP3Tag
PHP Script

How To

1. Copy Your Music

Use iBackupBot or iFunbox to copy the entire contents of your iPod's music folder.

2. Export SQLite Data

Use SQLite Manager to export the following tables with headers to CSV:

  • album
  • base_location
  • genre
  • item
  • item_artist
  • item_extra

3. Convert CSV To XML

The script is written to handle XML, not CSV. There are two options:

  • Change script to handle CSV
  • Convert CSV to XML with this site (preferred method)
    • Under Step 2, select "First row is column names"
    • Under Step 5, set "Each record XML name" to "item"
    • Under Step 5, click "Convert CSV to XML properties"
    • Save as item.xml
    • Repeat for each table in Step 2 and name the XML file same as each table name (ie. base_location.xml, genre.xml, etc.)

4. Move XML, Music And Run PHP Sciprt

After unzippping PHP Script package from above, drop all XML into "xml" folder, and music into "music".
Important: Make sure the original iPod folder structure stays intact (ie. music/iTunes_Control/Music/<Fxy>/<filename.m4a>)

Once everything is in place, run fix-ipod-music-filenames.php

6. Add ID3 With MP3Tag

Open all files in MP3Tag and select, Convert -> Filename - Tag. Match variables to filename (you can use the arrow to the right). Feel free to preview, click OK when ready.

Done!