I have thousands of scanned photos and would like to change the EXIF data to have the proper dates. I can do this all with exiftool, but am looking for a way to process the files after I have organized the files into groups by date.

I created subfolders with the format mmddyy and placed each photo for that date within.

I would like a script to do the following (Windows based computer, so DOS, powershell, or VBscript would work):

Step through each folder, take the date from the folder and apply the following commands:

exiftool -datetimeoriginal="19yy:mm:dd 12:00:00" directory\*.jpg
exiftool "-datetimeoriginal+<0:0:${filesequence;$_*=3}" directory\*.jpg
move *.jpg e:\Fixed\

Any suggestions? I haven't scripted in years and am definitely rusty.


1 Answer 1


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).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.