ExifTool Forum

ExifTool => Newbies => Topic started by: ethanfox on April 16, 2020, 05:48:31 AM

Title: Change date only (not time) based on filename
Post by: ethanfox on April 16, 2020, 05:48:31 AM
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.
Title: Re: Change date only (not time) based on filename
Post by: Phil Harvey on April 16, 2020, 07:18:43 AM
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 (https://exiftool.org/faq.html#Q5) 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
Title: Re: Change date only (not time) based on filename
Post by: ethanfox on April 16, 2020, 08:25:22 AM
Ah!  That did it.  Thank you so much - such a quick response, too!  Thanks!  Awesome tool this is.