Author Topic: Set Date Taken from File Name  (Read 6198 times)

rewallac

  • Jr. Member
  • **
  • Posts: 11
Set Date Taken from File Name
« on: July 28, 2017, 10:04:20 AM »
I have a folder of photos which have the date taken in the file name. How to I set the EXIF date taken from the file name?

2016-10-06_17-59-46.295790.jpg
2016-10-10_17-28-47.765140.jpg
2016-10-17_17-53-49.384150.jpg

YYYY-MM-DD_??-??-??.??????.jpg (Logically it would seem that the format is YYYY-MM-DD_HH-mm however, based on the content the hour/minute does not appear to me to be in the filename. However, I will accept those values as the hour/minute if I have to.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 15941
    • ExifTool Home Page
Re: Set Date Taken from File Name
« Reply #1 on: July 28, 2017, 10:13:12 AM »
If you do this:

exiftool "-datetimeoriginal<filename" DIR

then the year, month, day, hour, minute, second will be set from the file name.  (See FAQ 5 for why this works.)

If you want to set the minutes and seconds to zero, you can so this:

exiftool "-datetimeoriginal<${filename;$_=substr($_,0,13)} 00:00" DIR

This is assuming you want to set EXIF DateTimeOriginal.  You could also set CreateDate and/or ModifyDate if you want, or use AllDates (a shortcut tag) to set all three together.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

rewallac

  • Jr. Member
  • **
  • Posts: 11
Re: Set Date Taken from File Name
« Reply #2 on: July 28, 2017, 11:53:47 AM »
PERFECT!

THANKS PHIL!