Update: After reading this article, consider using the enhanced version of this script described in this article!
As a Linux addicted nerd you often face new challenges. One challenge could be migrating an existing iTunes database to a gnupod database, just to see that the database is completely broken in the end. And if it doesn’t work even after a gnupod_INIT.pl -restore, you definitely want to know how to recover the 14.000 mp3′s you’ve had on your iPod.
So here we go:
On a fat32 formatted iPod all the mp3 files still remain in the following directory even after the experience of a corrupted database.
user@host /mnt/ipod/iPod_Control/Music $ pwd /mnt/ipod/iPod_Control/Music
When you take a look into the directory you’ll see different subdirectories with the following naming convention and your actual mp3 files inside these directories.
user@host /mnt/ipod/iPod_Control/Music $ ls f00 f02 f04 f06 f08 f10 f12 f14 f16 f18 f20 f22 f24 f26 f28 f30 f32 f34 f36 f38 f40 f42 f44 f46 f48 f01 f03 f05 f07 f09 f11 f13 f15 f17 f19 f21 f23 f25 f27 f29 f31 f33 f35 f37 f39 f41 f43 f45 f47 f49 user@host /mnt/ipod/iPod_Control/Music $ ls f00/kpod0006400.mp3f00 /kpod0006400.mp3
To recover your files in a proper naming convention like “ARTIST/ALBUM/TRACK_NO.-TITLE.mp3″ you may want to grab the following shell script I’ve “quick’n'dirty-written” for this purpose. It’ll read files recursive from an input directory, get’s the id3v1 information from your mp3 files and copies them to an output directory. The input and output directory has to be defined by yourself in line 4 and 5. All files without an id3v1 tag will be copied to a subdirectory called no-id3v1 and therefore need manual care to refit them into your music library.
#!/bin/sh # define input/output directories input=/mnt/ipod/iPod_Control/Music/f* output=/opt/music/output # create no-id3v1 directory mkdir $output/no-id3v1/ # Let's do this... files=`find $input -type f` for i in $files do title=`id3tool $i | grep '^Song Title:' | sed 's/Song Title:\t//' | sed 's/[ \t]*$//'` artist=`id3tool $i | grep '^Artist:' | sed 's/Artist:\t\t//' | sed 's/[ \t]*$//'` album=`id3tool $i | grep '^Album:' | sed 's/Album:\t\t//' | sed 's/[ \t]*$//'` tno=`id3tool $i | grep '^Track:' | sed 's/Track:\t\t//' | sed 's/[ \t]*$//'` if [ -z "$title" ] then echo "!!! $i !!! --> $output/no-id3v1/$i" install -D $i "$output/no-id3v1/" else echo "$i --> $output/$artist/$album$tno-$title.mp3" install -D $i "$output/$artist/$album/$tno-$title.mp3" fi done exit
As always this small code snippet is ment to be sh-compliant and released under the terms of the GPL Version 2. Please be aware of the fact, that you’ll have to install the id3tool via your prefered package management software before running this script.
I’ll probably enhance the script so that it can be configured via an option parser, working with id3v2 information and different output formats as well. I’ll let you know when it’s finished.
[...] recently wrote about recovering mp3’s from an iPod which expierenced a database crash after e.g. messing [...]
Nice guide, this could be also used as extraction guide of music content from IPOD to hdd inside linux. As far I know only gtkpod supports this curently and on my machine it causes freezing and app failure (possibly bcos of number of tracks, 500 of them is ok to copy, but all of them are causing freezes). Anyway big thanks from me.