Create CD/DVD file indexes

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

Here’s a little tip to help you keep track of all those backup CDs and DVDs you’re burning. (You are making regular backups, right?). If you’ve got a full-bore backup strategy going, you’re probably copying most of your data to another hard drive (or perhaps to tape), and not to CD/DVD media—at only 700MB or 4.3GB, CDs and DVDs are not the most efficient storage solutions for today’s gargantuan hard drives.

However, you may still find CDs and DVDs to be practical for creating backups of smaller critical data files—things such as Word and Excel documents, photos, financial records, music collections grouped by artist or CD, and so forth. In my case, I use DVDs to back up my iPhoto library, and CDs for our Quicken records and some -related files (in addition to regularly backing everything up to two external hard drives).

One of the challenges with backing stuff up to CD or DVD is remembering what files are on which CD or DVD. There are third-party apps that will catalog your data for you, of course, but if you’re running OS X 10.4, you can do a pretty good job of it yourself using Spotlight.

Start by creating a directory for your CD and DVD indexes somewhere in your user’s folder. For purposes of this article, we’ll assume it’s named Media Index , and located in your user’s Documents folder.

What to do

First, burn your CD or DVD as usual. But before you eject it, open Terminal (in /Applications -> Utilities) and enter these commands, pressing Return after each:

	cd /Volumes

These two commands first change to the Volumes directory (the cd ) and then list (the ls ) the names of all the storage media (hard drives, CDs, DVDs) on your machine. You should see an entry for the CD or DVD you just created—let’s assume it’s named 2005 iPhoto archive . Now type this command in Terminal:

cd "2005 iPhoto Archive"

Obviously, replace the text inside the quotes with the name of your burned disc. We’ve now moved into the directory on your actual burned disc. Now we’re going to tell Terminal to catalog every single item on that disc, and save that data into a file. There are two similar commands you can use to do this. The first version below will produce a file that looks like this:


The second version produces a longer entry with more detail:

	380750   0 drwxrw-rw-   10 user  user  340 Nov  4  2005 ./somefile.txt

492912 0 drwxrw-rw- 10 user user 992 Aug 7 2006 ./z_otherfile.txt

The second version, which obviously results in much wider lines, contains information on every file’s permissions, owner (the first user in the above example), group (the second user ), size ( 340 ), modification date, and then the file’s name and path. Which version you use is completely up to you.

The short version:

find . > "~/Documents/Media Index/name_of_cd_or_dvd.txt

The long version:

find . -ls > "~/Documents/Media Index/name_of_cd_or_dvd.txt

In both commands, replace name_of_cd_or_dvd.txt with the actual name of the CD or DVD, as seen when you did the ls in the Volumes directory. The first part of this command simply finds every file at or below the currently chosen folder. (The long version adds -ls, which is what gives the detailed directory listing. Advanced Unix users can use cut to control which columns of output wind up in the final file.)

The output from these commands would normally go to the Terminal’s screen, but the greater-than sign redirects the output to the file listed to the right. When the command finishes running, your index file has been created. You can verify this in the Finder by simply opening your Media Index folder.

So now what

Now you’ve got an index of every file on the CD or DVD you just burned. If you’re ever in need of a file you burned to a disc, you just need to remember part of its name—run a Spotlight (Command-Space) search for that name, and one of the matches will be the “real” file on your hard drive. Another match, however, will be the entry for that file in one of the index files in your Media Index folder. Simply seeing the index file’s name in the Spotlight results list will tell you exactly which CD or DVD you need to drop into your machine.

So there you have it: a homemade, fast, and completely free indexing system for your backup media.

Note: As I mentioned in Thursday’s hint, I’m on the MacMania 5 cruise —look for dispatches from me and Dan Frakes next week in the MacMania blog. Since I’ll be bobbing around the Western Caribbean as you read this, I may not be able to respond right away in the forum thread to any questions about this hint. Thanks for your patience.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon