Batch file renaming for photographers: special case!
OK, so yesterday and today I had an interesting shoot which has been a learning experience. I was documenting a laboratory experiment which was time sensitive and of patent legal importance (or is that legal patent?).
Halfway through the day I was made aware that the exact time of photography was of essence -- that is, not only did I need to capture things at the right times, but also the images' timestamps needed to match the clock time in the laboratory; Lab techs were taking notes and logging times of experiments while I was taking photos, but also independently of photography.
After a bit of research, we figured out that "camera time" was exactly 8 minutes ahead of "lab time" (well, I had traveled South to get there :P). I was shooting both handheld and to laptop -- thank goodness Capture One Pro gives the nod to the EXIF data from the image and not to time-of-import, so I only had one set of mismatched times to deal with!
Client and myself decided that naming the files with the lab time (that is, "actual" or EXIF shooting time minus 8 minutes) would mollify the legal eagles, as long as I ensured that all EXIF and RAW data remained intact.
So, I needed to batch rename the hundreds of images I took at the lab and put the names in a client-specified format. Not a big deal normally to batch rename a set of images -- this can be done from most photo editing software, from the finder (Automator!), and from a cool little app I use daily: A Better Finder Rename.
Note: From here on out I talk about ABFR, BBEdit, and --gasp!-- Excel. ABFR is Mac only, but they have a Windows counterpart available. I haven't tried the Windows application, but if ABFR is any indication, it will be sweet. :-)
So, again, I needed to batch rename the hundreds of images I took at the lab. Not a big deal normally; ABFR will take only two shakes to rename a set of files with the EXIF date/time stamp -- But, I couldn't modify the actual EXIF data, because it had to stay intact. It wouldn't have made it easier, anyway, to modify the EXIF data because I needed to rename the files with a time that was 8 minutes earlier than what EXIF said.
If I'd only had to rename 5, 10 or 20 images I probably would have knuckled down and done it by hand. But, I had to rename over 900 image files (300+ each of RAW, TIF, JPG) because I'd been so darned efficient in processing things overnight. :-P
So, I needed to do something quickly (courier on his way, within an hour-and-a-half to get the images on DVD) and with the tools I had at hand. I also needed to use tools which my client could potentially have or acquire, and/or figure out later on. If someone can tell me of a single tool to do all this, I will buy them a beer! Likewsie, any ways to compact this workflow will net a beer. :-)
At any rate, here's what I came up with using ABFR, BBEdit and Excel... Whew!, it seems like a lot of work but it is actually much smoother and quicker than reading through my novella here is. :-P I hope it helps someone else out in a time-crunch renaming deadline.
[This is from a Mac standpoint. Workflow will be similar on Windows, but with the usual differences]
-
In the Finder, select all your files you want to rename
-
Control click to open a context menu, and choose A Better Finder Rename
-
Export a tab-delimited file list from A Better Finder Rename application:
-
Activate multi-step rename interface
-
Replace text at beginning with [arbitrary], leaving unique consecutive serial number
-
Add a second step (using the plus + sign
-
Change only filename, add date/time to beginning
-
Date: yyyy-mm-dd
-
Time: hh_mm_ss (24 hour clock)
-
Date-time
-
Add a trailing space (yes)
-
Use: digital camera exif date
-
Choose to Save File List
-
Advanced Template, if you want the file path included in the lefthand column (the original filename). Be careful, because the find-replace steps below could alter the original filepath too, if you use _ in yourfolder names.
-
This list contains original filename, plus filename as it would beif changed to the EXIF metadata timestamp (capture date/time from camera)
-
The consecutive number at end of each original filename is preserved, to avoid same-name conflicts between files who have the same timestamp (that is, sometimes more than one image was captured within the same second: say, 092526, where 09 is the hour, 25 is the minute, 26 is the second)
-
Open the tab-delimited file in BBEdit (text editing/coding application, which allows for disjointed and complex find/replace actions)
-
Insert tabs (essentially adding columns) between datestamp, timestamp, and file extension in the NEW NAME column at right
-
Example new name: 2007-04-24-09_25_34-00009.jpg
which is in format of: yyyy-mm-dd-hh_mm_ss-serial.jpg -
Find: 2007-04-24-
Replace: 2007-04-24-\t -
\t means tab
-
Find: -
Replace: \t\t- -
Note there's a space before the - in the find
-
The replace step adds an extra empty column after timestamp, which we'll use to hold new calculated timestamp;
-
Find: .jpg
Replace: \t.jpg -
Find: \$?([0-9,]+)\_(\d+)\_(\d+)
Replace: \1:\2:\3 -
OK, it looks garish I know. Whew, I had to reach back a couple years to my first semester UNIX class at Berkeley. :-P
This Find/Replace lets you change the timestamp from something like 09_25_34 to 09:25:34
This Find lets us change ONLY the timestamp; that is, some numbers followed by an _, followed by some numbers, followed by an _, followed by some numbers.
For this Find/Replace you will need to check the box in the Find dialog window for Use Grep. Grep and BBEdit are powerful tools.
-
We need to change the underscores (_) to colons (:) so that we can use a calculation to change the timestamp. A Better Finder Rename wouldn't let us use semicolons (for good reason), so we need to change it here.
-
Note: The first time I did this, I exported the file list from A Better Finder Rename without anything between the digits in the timestamp (092534 vs 09_25_34);
I was thinking I could simply subtract 800 from the timestamp (changing the minutes, but leaving the hours/seconds intact). Easy, right?
This becomes a problem, because if you simply subtract 800 from a timestamp like 200145 you end up with 199345 (which isn't a valid timestamp) when what you want is 195345.
-
Save file or save file as: [arbitrary].
-
Open tab-delimited file in Excel. OPEN it, don't IMPORT it. I dragged the text file onto the Excel application icon.
-
In my example, the timestamp and empty column to its left (the extra \t, remember?) are C and D.
-
Select the columns C and D, and Choose Cells from the Format menu.
-
Choose Time, and the format 13:30:55.
-
Calculate adjusted timestamp, by subtracting 8 minutes, and have calculation entered into Column D at right of original timestamp.
-
Select the first cell in Column D.
-
From the View menu, choose to show your Formula bar if it isn't already visible.
-
Click the Calculator on the Formula bar. Click the first cell in the C column (C1), then click the minus button on the calculator, then click the minus sign on the calculator, then type in the number: 0.005555556 (equivalent to 8 minutes in Excel-ese).
You should have a formula which looks like: =C1-0.005555556
-
Apply your formula, and the timestamp should now look something like 20:33:00 --> 20:25:00
-
Do the dragging-down-thingy in Excel to apply the formula to your entire "D" Column. Your timestamps should now look something like:
C D
20:34:42 20:26:42
20:35:03 20:27:03
20:35:03 20:27:03
20:01:57 19:53:57
20:01:57 19:53:57
20:02:28 19:54:28...and so on.
-
Note: Manipulating time in Excel is a black art. Most of Excel is a black art. View the Help in Excel for more info on how Excel uses decimal values to allow us to add and subtract time.
-
Note: The decimal equivalency isn't the black art, it's how you get to it in Excel that is the black art. :-P
-
Save your altered file or save as a new tab-delimited file, keeping it in the same format when Excel squawks at you.
-
Close the file in Excel (w/o saving, since you already did that)
-
Open new file in BBEdit
-
Go to the top left of your original timestamp's column, and put your mouse
pointer there. Hold down the option key (I LOVE being able to select columns
like this in BBEdit) and drag down to select the entire column. Delete it. -
Caveat Emptor: Be careful, if you have filenames and/or timestamps of differing
lengths, you may select more than or less than you want; Be aware. You may
have to do this in several passes. Please, someone, tell me there's a way to
automate this. :-) -
Undo your Grep mania from before (the "\$?([0-9,]+)\_(\d+)\_(\d+)"), with a minor change:
-
Find: \$?([0-9,]+)\:(\d+)\:(\d+)
Replace: \1_\2_\3This will take you from 09:17:34 to 09_17_34.
-
Note: In the Find dialogue window, NOW uncheck Use Grep.
-
Remove extraneous tabs, using Find/Replace, so that your filenames are whole
again and tab-free. -
Find: 2007-04-24-\t
Replace: 2007-04-24- -
Find: \t\t-
Replace: - -
Find: \t.jpg
Replace: .jpg -
Note there's now NO space before the - in the replace
-
In the Finder, select all your files you want to rename
-
Control click to open a context menu, and choose A Better Finder Rename
-
Choose to Change File Name and Extension
-
Choose to Rename from File List
-
Choose your tab-delimited file
-
Go! Your files are now renamed...
--
This workflow was used in the same manner for both TIF and JPEG files. All I did
for the TIF files was Find/Replace .jpg with .tif. Nice!
nb: always work in copies. don't try this in a conspicuous place until you're comfortable with it. this is free advice. :)
Re: Batch file renaming for photographers: special case!
Thanks Aldo -- and, no special reason other than an itchy trigger finger. I'd meant to toss the blog post into a not-live status, but didn't. Is it bad form to remove a blog post?
Devlin: I haven't really looked at Lightroom yet, but I did look at Bridge. Bridge will let you rename files in batch, but can't do the metadata + time conversion stuff. Actually, nothing I own could do it in one go -- thus, this workflow. :)
Patrick Cheatham
--
CheathamLane | spinControl:VR
Berkeley, California
VR Photography
Web, Flash & QuickTime Development
Re: Batch file renaming for photographers: special case!
> Is it bad form to remove a blog post?
It's your blog ;-)
Re: Batch file renaming for photographers: special case!
Ha, cool! "It's my blog and I'll cry if I want to, want to, want to...". I suppose it is.
Well, now it's being linked to by the A Better Finder Rename creators at their blog -- so I guess it would be bad form NOW.
Any way to make the forum post link to the blog post if the forum post is pruned or removed?
Patrick Cheatham
--
CheathamLane | spinControl:VR
Berkeley, California
VR Photography
Web, Flash & QuickTime Development
Re: Batch file renaming for photographers: special case!
You can prune/graft the comments onto your blogpost, and edit this forum post to point to your blog... Or I can do it for you. Let me know.
Re: Batch file renaming for photographers: special case!
It does sound like a complex workaround, but off-hand I can't think of any automated software that would do it in an easier manner. Quite a few conversion/cataloguing apps will change the timezone, but that only gives you one hour increments...
Ian Wood
Landmarks of Britain
Azurevision
Re: Batch file renaming for photographers: special case!
Does anyone know if Adobe Lightroom would have worked for the renaming?
I'm trying to understand why Lightroom is better than Bridge for asset management.
Re: Batch file renaming for photographers: special case!
Sadly, LightRoom is a bit... 'lacking' when it comes to digital asset management tasks. :-(
Ian Wood
Landmarks of Britain
Azurevision
Re: Batch file renaming for photographers: special case!
I use InnoRename to rename my huge picture files from my photo and my mp3 files too.
Great program to try (find it there www.innoplanet.com).
It can be programed and you can do a lot of combination easily.
Try it.
Re: Batch file renaming for photographers: special case!
I Usually do this with EZ Photo Renamer. It can quickly rename many digital photo files which are generated by digital cameras.

Re: Batch file renaming for photographers: special case!
nice writeup. Any reason in particular for the double post?