Tuesday, 27 September 2011

Trying to find and get software to work to do something I've already done

I spent most of today writing a photography article.

Then in the evening Billy said he had accidentally deleted all the Animal Crossing photos off the SD card, but he pulled the card out of the wii as soon as he realised so could I check if the card was corrupted or the photos still there. First my PC didn't seem to recognise the card at all, even after removing it from the card reader and removing the card reader from the PC and then re-inserting them again. So I checked Windows Device Manager, which showed the device as a USB Mass Storage Device, but said that the device had been marked for safe removal, but hadn't been removed yet. It said to use the device remove it and then re-insert it again (or something similar).

I didn't think that would work since that was exactly what we'd already done, but I did it and it worked. Hmm... strange. I checked the card and it worked okay, but all the Animal Crossing photos had been deleted, so obviously the Wii was quicker at deleting the photos than Billy thought.

I tried Handy Recovery, some old recovery software I have. This recovered some of the files, but the large majority that it recovered displayed no thumbnails in Windows Explorer, and said the file was corrupted or a type that:

Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large

I thought that maybe specialist image recovery software might work better at recovering the the photos. After doing some googling I remembered that Sandisk Memory cards come with free photo recovery software. I found the website online, and downloaded a demo of the SanDisk RescuePro software. This seemed to show all the photos okay, indicating they could be recovered, but it cost about $60-70 for the full non-demo version that could actually recover the files. So rather than pay $70 for a piece of software that comes free with a memory card, I thought I might as well try and find one of my Sandisk memory card boxes that included the RescuePro software.

I got the 2 boxes of photo stuff boxes out of the garage, then Billy had a look and managed to find a 4GB Sandisk Compact Flash card box, which was the first CF card I bought with my Nikon D200, quite a few years ago. I checked the back of box, and was surprised to find that the RescuePro software was included with the card. But when I took the plastic packaging out of the box, there didn't seem to be any serial number or CD. Then after checking the pamphlet and stuff that was inside the plastic interior packaging, I gave up and decided to put it back in the box. After all, I still had two other newer Sandisk memory card boxes somewhere I could check.

But when I was putting the plastic interior packing back in the box, I found that actually the (mini) CD was in the box, rather than in the plastic packaging. So I installed the software, but when it came to start it, it wanted a serial number. I couldn't see one on the mini CD wallet, or the main box, or anywhere in any of the stuff that was in the box. I checked and checked, and tried a couple serial numbers that were on the bottom of the box, but they didn't work and I couldn't see the correct serial number anywhere. So I had to give up on that.

Doing some more searching through the big boxes of photo stuff, I found a SanDisk 4GB SD card box. This included the RescuePro software as well, and the serial number was printed on the back of a sticker on the mini CD wallet. Woohoo! First I tried entering the serial number in the prompt of the RescuePro software I'd installed from the Compact Flash card's CD. But this didn't work. So I uninstalled both the previous version (3) of RescuePro and the Demo version (3.5), and then installed the version that came with the SD card (3.3).

After entering the serial number, the program started up, but said it couldn't read the SD card!?!

I decided to check how much of the photos Handy Recovery had recovered, and thought that maybe it wasn't very good at recovering them all in one go but might do it if I only selected a few at a time. But when I checked, I found that actually it had recovered all the same photos that the Demo of the latest version of RescuePro had been able to show it could recover, So after spending all evening on this, Handy Recovery had actually worked fine. It was just that it had also 'recovered' hundreds of additional photos that couldn't be recovered fully and so were corrupted. These were probably photos that had been deleted from the card before, while the ones deleted this evening were able to be recovered.

Now I knew I had the files recovered okay, it was just a case of moving them to the correct directory for permanent storage. In hindsight I didn't need to do this, but at the time I thought that I needed to rename the files, as the recovered files all had filenames like _UU_00001.JPG while the existing files had filenames like RUU_00001.JPG. So I thought I needed to replace the starting underscore with an R to match the correct file naming system for Animal Crossing photos. Of course, once the photos are stored on your PC, it doesn't really matter what their filename is actually.

Anyway, I thought it did matter for some reason, so I tried to see how to batch rename the files. Unfortunately I couldn't find any info other than pay for software. If I was using Linux I'd probably try and write a shell script, but since I'm on Windows I thought I'd try and write a perl script instead. I'm probably equally useless at perl and bash scripting anyway. After some more googling I got the script written, but it didn't work. After doing some debugging I found the problem was that the filename held in the variable started with a './', which I wasn't expecting (though now I look at the script, it's obvious). So I adjusted my script and got it running okay.


use strict;

my @files = <./*.JPG>;
my $file;
foreach $file (@files) {
  if( rename($file, 'R'.substr($file, 3)) )
    print "$file renamed\n";
    print "Problem renaming $file\n";

print "Operation Complete";

I just saved that as rename.pl, put it in the directory of photos, and then double clicked it to run it. With a bit of googling I'm sure it could be changed to use a regex replacement and do more complex batch renames.

And since I had to clear some photos off my memory card today, here is one from a few days ago showing some armatures in varied state of dress:

No comments: