Change date only (not time) based on filename

Started by ethanfox, April 16, 2020, 05:48:31 AM

Previous topic - Next topic

ethanfox

I'm sorry, I'm sure this has been answered.  I've found many posts very similar to what I'm trying to do, but can't quite figure out the right command to get this to work.  Thanks for any help - this is an awesome tool.

What I have: jpg files with filenames that all START with the correct date YYYYMMDD_filename.jpg but no time in the filename. 
What I want: Change the date of EXIF field [Date/Time Original] to match the date in the filename (first 8 characters) but leave time in the field unchanged.

Trying to run a command that will execute this for all jpg files in folder and all subfolders.

Thanks again.

Phil Harvey

Hi Ethan,

Try this:

exiftool "-alldates<${filename;s/_.*//} ${createdate;s/.* //}" DIR

The advanced formatting expression for FileName removes everything from the underline onwards, and the one for CreateDate removes everything up to the space. (And FAQ 5 explains the input date/time formatting.)

AllDates is a shortcut for CreateDate, ModifyDate and DateTimeOriginal, so all 3 of these will be updated in the command.

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

ethanfox

Ah!  That did it.  Thank you so much - such a quick response, too!  Thanks!  Awesome tool this is.