Runtime Revolution
 
Articles Other News

iPod backup: Making successful freeware with Revolution

by Mark Smith

Profile:

Mark Smith is a former Hypercard user who moved over (with much relief) to Revolution in 2002. He has also programmed quite a bit in OPL (Psion handhelds) and a bit less in Forth, but sticks almost exclusively to Revolution, these days.

He is a musician by occupation (bass guitar, mainly), visit his site at: marksmithbass.com. He lives in London.

The problem: I have an iPod with around 30000 songs on it, which have come from various different computers I've owned at different times. I have no single iTunes library which contains all the songs on the iPod, and consolidating it all seems tricky, since iTunes won't easily let you copy files from an iPod. So I want to simply copy all the songs off the iPod on to an external hard drive as a back-up. If I ever need to restore from the back up, I can point iTunes at the back-up, import all the songs and then copy them back to the iPod.

I don't want to crack any copyrights, I just want to be able to backup my iPod to wherever I want.

So time to try making a solution in Revolution.

The first problem is that the song files on the iPod are hidden, so it's not as simple as just getting a list of the files in the normal way. Except, after a little research, it turns out that it actually is that simple. All I needed to know was that all the files are kept in a hidden folder (and sub-folders) called "/iPod_Control/Music", at the top level of the iPod, and though they don't show up in standard file selector dialogs, they can be accessed by the normal file handling commands in Revolution.

So I have a 'directory-walker' function and I let it loose on the hidden 'music' directory and now I have a list of all the song files.

Now I find that iTunes (in the last few versions, anyway) gives the files names such as 'F6TG', and maintains a database of what the files actually are, so the file names give you no clue as to whether it's Mozart or Metallica. I delved into the iPod database format, and actually wrote a handler that could read it, but the format has changed over time, and will doubtless change again, so I abandoned that approach and decided to deal with the files directly.

Fortunately, all the files have 'tags' (metadata containing information about the file, such as 'title', 'artist' etc), and it so happens that I wrote a Revolution library for reading these tags a while ago (id3Lib). So I can just loop through the list of files, read each one's tag, and copy it to a hard drive with the right title. I made the decision, for the sake of simplicity to build a folder structure on the destination drive that organises the file into sub-folders by Artist, Album and Title.

Now it was time to make a usable interface. I decided to delve into Revolutions drag and drop capabilities, which I hadn't used before. It turns out to be very simple to have a field on to which you can drag an iPod, and then show the name of the iPod when it's 'dropped'. Since you now have the iPod's name, you can then create the path to the hidden 'music' folder, and get the list of files in it.

I did the same for the destination - you drop a folder on to the 'destination' field, and that folder becomes the destination for the backup.

Then, since the process of copying thousands of files is likely to take some time, I added some progress indicators: of course, a progress bar, and another field that is updated as each file is copied with the title of the file, the number of files copied so far, and the number of files to go.

I also realized it would be necessary for the user to be able to interrupt a backup, so when copying, the label of the 'copy files' button changes to "hold down the control key to stop". I think this method could be improved in a future version of the programme, but it works well enough as it is.

Finally, I wanted the programme to keep track of what has already been backed up, so I used a scheme whereby the source and destination paths of each file are stored in a custom property set of a stack file which is saved in the application support folder on the host computer. I also now think this could be improved by storing it with the backup itself, but that is also for the next version.

Having got the whole thing working reliably, I thought it might be useful to other people, so I put it up on VersionTracker as freeware. It's had over 8000 downloads, so far, and some very positive feedback, 4.5 out of 5 stars. The program is also to be found on numerous other download sites, and seems to be reasonably well liked by people who use it. I don't intend to add any other features, as I'd like to think that it falls into the category of software that does just one thing, and does it simply and well.

It's also available from my own website, (which also has some other Revolution stuff).

I've only released it for Mac OS X, as I have no other kind of computer to test it on, though there is nothing that I know of in it that would break under any of Revolutions' supported OSes. Since it seems to have survived quite well in the OS X "wild", I now need to find testers for Windows and Linux...

Editors note: If you'd like to volunteer as a tester for Mark, email editor@runrev.com and we'll put you in touch with him.

 
©2005 Runtime Revolution Ltd, 15-19 York Place, Edinburgh, Scotland, UK, EH1 3EB.
Questions? Email info@runrev.com for answers.