Set datetime from foldername

Started by Soulplayer, August 27, 2023, 03:21:43 PM

Previous topic - Next topic

Soulplayer

Hello,

I've been using this tool to fix some missing EXIF dates. Most of my files are now complete (thanks!) but I have some annoying files that don't have the date in the name but in the folder:
Folder name: 2018-01-04
inside folder filename: IMG_0108.JPG

Is there a way to use exiftool to use the date from the folder?

exiftool "-datetimeoriginal<foldername" ./ -> I tried this but ofcourse it does not work :).


Thanks!

Phil Harvey

This should work if the date is the only number in the folder name.  First "cd" to the folder containing the date folders, then run this command:

exiftool "-datetimeoriginal<$directory 00:00:00" -if "not $datetimeoriginal" -r .

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