How can I batch-set scanned photos' EXIF dates from mmddyy folder names with ExifTool on Windows?
Asked 10/15/2020
3 views
2 answers
0
I have thousands of scanned JPEGs on Windows and want to set each file’s DateTimeOriginal based on its parent folder name. Each folder is named in mmddyy format, and the photos inside that folder all belong to that date.
Ideally, I want a batch process that:
- Reads the date from each folder name
- Writes that date to
DateTimeOriginal(for example19yy:mm:dd 12:00:00) - Optionally offsets each file by a few seconds so they sort uniquely
- Moves the processed JPEGs to another folder
Is there a way to do this directly with ExifTool, without needing a separate DOS/PowerShell/VBScript script?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
5y ago
2 Answers
3
This can be done by exiftool without scripting. To set the time stamp, you could run
exiftool -ext jpg "-DateTimeOriginal<19${Directory;m/(\d\d)(\d\d)(\d\d)/;$_=$3$1$2} 12:00:00" /path/to/mmddyy/
Then the incrementing and moving of files can be done with
exiftool -ext jpg -Directory=e:\Fixed\ -overwrite_original "-datetimeoriginal+<0:0:${filesequence;$_*=3}" /path/to/files/
The first command takes the directory, looks for 6 consecutive numbers which it assumes is the mmddyy, reorders them and applies the result to the DateTimeOriginal. Colon separators are not mandatory for this, see Exiftool FAQ #5, 3rd paragraph which starts "Having said this…". This command does require that the mmddyy part of the path is on the command line. You can't CD to the directory and use a dot as the directory name. If would also required refinement if there was another pattern of 6 consecutive digits somewhere else in the filepath.
The second command increments the time on each image. Additionally, it will move each edited file to the e:\Fixed\ directory as it updates.
In both cases, I used the -ext (-extension) option rather than a wildcard, because wildcards won't work in case you have to recurse into subdirectories (see Common Mistake #2).
Originally by user37960. Source · Licensed CC BY-SA 4.0
user37960
5y ago
0
Generated from our catalog & community — verify before relying on it.
Yes. You can do this directly in ExifTool, no separate script required.
Set DateTimeOriginal from the mmddyy folder name:
exiftool -ext jpg "-DateTimeOriginal<19${Directory;m/(\d\d)(\d\d)(\d\d)/;$_=$3$1$2} 12:00:00" /path/to/mmddyy/
Then increment each file’s time and move the files:
exiftool -ext jpg -Directory=e:\Fixed\ -overwrite_original "-DateTimeOriginal+<0:0:${filesequence;$_*=3}" /path/to/files/
How it works:
Directoryreads the parent folder path.- The regex extracts the 6 digits from the folder name as
mm dd yy. - It reorders them to
yy mm dd, which ExifTool accepts for the date. - The second command adds 3-second increments using
FileSequenceso files sort in order. - Setting
-Directory=moves the processed JPEGs to the destination folder.
Important: the folder containing the mmddyy name must be included in the path you pass on the command line so ExifTool can read it from Directory. Always test on a copy first.
Recommended products
UniqueBot
AI5y ago
Your Answer
Related Questions
How can I batch-set EXIF dates from a parent folder name in ExifTool?
How do I use ExifTool in PowerShell only when DateTimeOriginal is missing?
How can I set photo EXIF dates from the folder name?
Why does ExifTool shift times by 1 hour when copying FileModifyDate to EXIF dates around BST/GMT?
How can I batch-edit EXIF date/time for multiple photos across a time range?