By training, I am a programmer. Its something I enjoy and use to my advantage whenever possible. In this case, I had a repetitious task to perform and so I made a PERL program to solve it.
This past Monday, while working from home, my DSL went out for several hours. Since I was stuck on site fielding questions from the Support team, I started tinkering with a program I use to copy Nikon NEF files from a flashcard reader.
Basically, I like to sort my files in directories by camera model and date. That is, if I take a photo with my Nikon D80 on May 20th, 2007, I'd copy them into:
Sounds simple, but suppose I put two weeks of photos on a 2 GB memory card? Doing it manually is a pain and I'm lazy. So I wrote a PERL program to do it.
Here's How it works:
- Get a directory of the memory card (G:DCIM100ND80)
- Load the EXIF info from each file, one at a time
- From the file, determine the Camera Model and Date it was taken.
- Get some stats from the EXIF Info.
- If the destination directory does not exist, create it (c:StuffStefanNikonD802007-05-20)
- Copy the file
- Go to the next file.
A colleague asked for a copy, so I niced it up, commented it, added command line parameters and I'm releasing it into the wild.
Prerequisites: PERL, of course and ExifTool by Phil Harvey. Frankly, Phil Harvey did all the heavy lifting here. He wrote a great PERL module and I'm only using a little bit of it. The rest is just simple file manipulation.
From a command line:
c:> perl copyNEFJPEG.pl -?
[–from X:] (e.g. –from i:) Default = i:
[–to X:somedirectory] (e.g. –to X:somedirectory)
Default = d:StuffStefan
[–writecfg] Write config file to "copyNEFJPEG.cfg".
[–nothing] Do Nothing, just show me.
[–usage|help|?] This message.
c:> perl copyNEFJPEG.pl –from g: –to c:stuffStefan –writecfg –nothing
In this case, it will write a file called copyNEFJPEG.cfg to the same location as copyNEFJPEG.pl and set the defaults to the command line (Assuming "c:stuffStefan" exists in advance). The "–nothing" parameter shows what it would do without doing any copying (other then the config file that is) . Next time, you would simply use:
c:> perl copyNEFJPEG.pl
and it will just copy the files (Did I mention I'm lazy??). Once the config is done, you could just set it up as a shortcut. This program won't overwrite anything or delete the source files. It's fairly harmless, but if you use it, do so at your own risk. I've used this on Nikon NEF files and JPEG files. Likely it would work on CANON RAW files, but I don't have any to test. If anyine wants me to test with CANON RAW files, leave me a comment.
You can download it in a zip here.
Music I'm listening to right Now:
"The Taste" by Five for Fighting from "The Battle for Everything". Five for Fighting is John Ondrasik.