Copy artists/albums from iPod to computer

Aug 25, '03 09:14:00AM

Contributed by: meELOISE

I recently filled up my 10 gig iPod with ripped music from my CD collection. Because my hard drive only has three gigs available, I deleted them off my hard drive after copying the music to my iPod. After I was done with this entire process, I decided I wanted to back all the files up to Data CD so I wouldn't have to rip them in the future. Then I smacked myself in the head when I realized I couldn't easily copy the music from the iPod to iTunes.

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:

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030602155327895