During the image recovery process described in the previous post, some of the retrieved images got funny names. Usually, my camera (a Canon EOS 10D) produces two files per photo when using the RAW mode. The names of these files are in the form CRW_0123.CRW and CRW_0123.THM. The .CRW file contains the actual image data, and the THM file is a sidecar file containing a JPG thumbnail of the photo, along with some EXIF data. During the recovery operation I got a number of files named like this:
V0000001.CRW
V0000002.THM
V0000003.CRW
V0000004.THM
...and so on.
Since every second file was CRW and every other file was THM, I figured that the recovery software just didn't manage to find the file names of these files and just gave them a sequence number instead. The file formats, however, were kept intact.
I wanted to restore the original file names, in order to see if there were any gaps in the file name sequence, which would indicate that there were images that were not restored. Enter EXIFTool. This is a most powerful tool when it comes to anything related to exif data.
Using exiftool, I inspected the exif data of a couple of CRW and THM files and it turned out my thoughts were correct; these seemed to be file pairs belonging together. One of the exif fields is named "File Number", looking like this: 322-2254. The corresponding name of a CRW file would be CRW_2254.CRW. So, all that was needed was to extract this number from each file and renaming the file using that number. The following commands took me a bit on the way:
exiftool.exe "-filename<${filenumber}.CRW" *.CRW
exiftool.exe "-filename<${filenumber}.THM" *.THM
Now I had a sequence of files named like this instead:
322-2254.CRW
322-2254.THM
322-2255.CRW
322-2255.THM
...and so on.
To completely restore the filenames, a simple rename command was used:
ren ????????.* CRW_????.*
There, filenames restored. When copied into the archive I found that only two files were missing, and those were actually deleted by me immediately after the files were restored (they were simply too bad).
I am quite sure that there is a way to do this so that all files could be handled at the same time, instead of running it once per file extension, and that would also give the files the correct names from the start, but it was not really time consuming so I decided not to dive into that at this time. If you happen to know the way to do this, feel free to post a comment.