Recovering lost files

Something very strange happened to me a couple of days ago. I was dragging files between folders in the Finder and all of a sudden I seemed to drop them into somewhere unexpected, and a bunch of files just disappeared. Boom! Gone! They weren't in the Trash bin or anything. Where were they? What had happened? What was that place where I had dragged them without knowing that? I had no clue, no way to replicate it and no way of undoing it either, since the "Undo" option wouldn't undo anything useful.

Since the missing files were pictures and I always store the original camera files without renaming them, I noted the names of the files in the preceding folder, and then tried looking for the next file in the sequence. E.g. if the previous folder's last file was IMG_0100.JPG, I looked for IMG_0101.JPG:

cd photos
find . -iname IMG_0101.JPG

I tried several variations, even resorting to IMG_01*.JPG. I got several false positives, as I've had this camera since 2007 and according to the camera counter I've shot more than 100.000 photos already!

In desperation, I moved to the root directory and attempted searching there.

cd /
find . -iname IMG_0101.JPG

That didn't work either. I was starting to resign myself to the fact that I had lost the pictures in such a silly stupid way, forever. At least I had some copies--I had uploaded the best pictures of that day to my photography site! Although that slightly alleviated my pain, I still felt angry about the whole situation. It's the second time I lose pictures for no reason, and coincidentally a Mac OS system was involved on both occasions.

The first time this happened, the SD card simply appeared empty. No files. I used FileSalvage by Subrosa Software, and it worked well--I could recover all the files that had mysteriously disappeared from the memory card. So I thought I could try with it again, and hopefully that would fix my problem. Alas, that was in 2007, so this computer and operating system version didn't even exist back then. And Subrosa haven't been resting on their laurels, and have released newer versions of FileSalvage, which meant that the quite expensive license I paid for back then was rather useless now, unless I wanted to upgrade for half the price of a license. What a deal, eh!?

The free trial allows you to scan for "lost" files in the free space of a volume, but doesn't allow you to recover them. And I couldn't find my license number or old versions of the software on their site either. So what to do? Buy another license again, just to find that it's useless five years later?

No way!

Ladies and gentleman: welcome PhotoRec!

A maybe-not-as-fancy text mode/curses application that serves the same purpose that FileSalvage does, but for free! And it's open source too. What else can you ask for?

After about 10 minutes of scanning, I can happily announce that PhotoRec has been able to recover the pictures that Mac OS mysteriously lost! Yay!

One final tip: As scanning the entire hard disk would be "killer", I just scanned the SD card that I used to take those pictures. Luckily, I hadn't taken enough pictures after "deleting" the previous ones, so the "deleted" pictures hadn't actually been deleted.

Happy file recovering! \o/