Previous hints detail how to get to the raw music files in a mounted iPod, but I wanted to make sure I copied whole albums at once. Since my available HD space was less than that being used on iPod, I couldn't copy the entire store, and since Apple used hashed folders to store music on the iPod and albums could be split into multiple folders, I couldn't just copy a hash folder at a time. Read the rest of the hint for the solution to this problem.
[robg adds: Based on the comments posted when this was an "Is it a hint?" entry, here are two things to note: The posted script requires the non-free ksh shell; one commenter noted that a previous hint explains how to use the zsh to emulate ksh. Also, another commented noted the iPod Tracks -> Desktop script from faqintosh.com.]
My solution was to write a perl program to parse the iPod's music database which references all the track's pertinent information with the files' location on the iPod. The program is here:
http://www.jetmore.net/john/code/parse-ipod-db
Using this script, I was able to build a unix pipeline to do whatever I wanted with the data files. In my case I copied Artists whose names started w/ the same character to a folder called "music" on my desktop using the following shell script:
#!/bin/ksh
for i in `parse-ipod-db "/Volumes/John's iPod" |\
grep -i "^C" |\
awk -F'\t' '{ print $4 }' |\
tr " " ":"`
do
FILE=`echo $i | tr ":" " "`
echo $FILE
cp "$FILE" ~/Desktop/music
done
This runs parse-ipod-db on the iPod mounted on "/Volumes/John's iPod". From this output it grabs all tracks by artists whose names start w/ "C". Then it strips the output so it only contains the location of the data file for that track. The it temporarily replaces all space characters in the file name w/ colon characters (This is a hack - there might be a better fix, but I was in a hurry and this works - the colons get removed later). At this point we have a list of all the data files we want to copy. for each of these files, change the colons back to spaces, echo the file, and then copy it to the folder "music" on your desktop (which it assumes already exists).
Using this I was able to copy over whole albums to my harddrive and back them up to data CDs, which was the whole point. Maybe this will be useful to some other people, too.
Disclaimers:
- This is not widely tested software - it works well on my machine, which is OS X 10.2.6, iTunes 4.0, old style iPod running 1.3 software - any other setup may have a different DB format and may not produce meaningful output.
- Apple seems to use 2-byte chars in their file names, artists names, etc. My program blatantly ignores the high byte since I don't easily know how to deal w/ it and I didn't need it. This script may not work w/ non-english characters and will almost certainly not work for asian languages.
- That said, this script only reads from the database, it doesn't write to it, so if it doesn't work, you'll just get a bunch of errors, it _shouldn't_ break your iPod - but I offer no warranty =).

