Changing EXIF Create time based on filename.

Started by clem, November 24, 2014, 03:14:10 AM

Previous topic - Next topic

clem

I realize that I can rename files based on their EXIF date stamp. But I'd like to do it the other way and set all files EXIF creation dates based on their file which is their time stamp. (Reason: files are scanned photos, so EXIF time data is in no way connected to the actual date of the file).

Files are named in one of two formats:

YYYY.MM.DD.Frame#
i.e.
2001.08.01.01.jpg

or

YY.MM.DD.Roll#[space]Frame#.jpg

i.e. :

01.08.30.03 36.jpg


The photos are in hierarchical folders corresponding to the year/month/day/roll they are in.
i.e.


01
|-08
|--30
|---03
|----01.08.30.03 36.jpg


Realizing that I sometimes have 36-38 frames/roll, I'd be happy enough to make the frame a 'minute' past 'midnight', i.e. frame 36 to be 00:36 and a roll to be the hour. So the example immediately above  referring to the 36th frame of the 3rd roll of film shot on August 30th ,2001 could have a creation date of: 2001:08:30 at 03:36 (AM).

Is there a relatively straight forward way to do this? Thanks!

;D

Phil Harvey

It is easy enough to copy a date/time from the file name, and ExifTool will take the first 4 digits as a year, the next as month, etc...  Your only problem is that sometimes your Roll# (which would be mapped into hours in the date/time) is missing.  But we can fix this by adding it if there is no space in the filename:

exiftool "-datetimeoriginal<${filename;s/\.(\d+\.[^\.]+)$/\.00 $1/}" FILE

(the above quoting is for Windows.  Use single quotes instead on Mac/Linux.)

So I guess that answer to your question is "no".  There is no relatively straightforward way to do this.  (Unless you think that regular expressions are straightforward.)

Note that this will only work if the roll number and frame number are both 2 digits.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

clem

Super fast response. Thank you!

Constructing RegExp scares me — which is why I signed up here to ask the pros — but I don't mind, so long as it works. :-)

So if I use (in Yosemite Terminal) the


exiftool "-datetimeoriginal<${filename;s/\.(\d+\.[^\.]+)$/\.00 $1/}" FILE


will this also dig its way through the directories once I've changed the path to the root of the photo directories? i.e. recursive?


Phil Harvey

In Yosemite, use single quotes.  Also, add -r to recurse through directories:

exiftool '-datetimeoriginal<${filename;s/\.(\d+\.[^\.]+)$/\.00 $1/}' -r DIR

Note that you will be left with an "_original" backup for each file that is modified.  ExifTool may also be used to restore the originals, or delete the "_original" backups if you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).