Main Menu

Set Date Taken from File Name

Started by rewallac, July 28, 2017, 10:04:20 AM

Previous topic - Next topic

mbrijun

Hi, this is a very useful functionality I have been looking for. One additional question - can exiftool detect if "AllDates" metadata is already present and skip that file without modifying it? Thank you.

StarGeek

I wouldn't know how to do it in the GUI (which is no longer supported) but on the command line you can add the -wm (writemode) option, specifically -wm cg which will create new tags and groups as necessary but will not write to existing tags.

But one thing to realize is that AllDates is a Shortcut tag and if one or two of the tags that are part of the shortcut don't exist, then it would write to those while leaving the others alone.  This could show up as discrepancies between time stamps.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

mbrijun

Quote from: StarGeek on July 11, 2020, 03:11:50 AM
on the command line you can add the -wm (writemode) option, specifically -wm cg which will create new tags and groups as necessary but will not write to existing tags.

this is exactly what I was looking for, thank you!

greglec

Hi all, first of all many thanks for the really useful app! Saved me from having thousands of photos badly dated.

I have been updating the dates from the file name very well for many but, on some photos, I am struggling with the filename parsing.

They are named as such: 'Photo on 02-01-2016 at 11.55 #3.jpg' or  'Photo on 02-01-2016 at 11.57.jpg'

I am trying the following command : 'exiftool -d "Photo on %d-%m-%Y at %H.%M" "-alldates<filename" DIR'

But I am getting the following errors :
Warning: garbage at end of string in strptime: .jpg in ExifIFD:DateTimeOriginal (PrintConvInv) - Photo_on/Photo on 17-11-2015 at 21.13.jpg
Warning: No writable tags set from Photo_on/Photo on 17-11-2015 at 21.13.jpg

I am assuming that I need to ignore the characters in the file name after the minutes with input such as '${Filename;s/\.[^.]*$//}' but I am a bit lost on how to use it.

Any help?

Many thanks in advance.

Phil Harvey

strptime is very picky about the syntax, but I think this should work:

exiftool -d "Photo on %d-%m-%Y at %H.%M.jpg" "-alldates<filename" DIR

If that doesn't work, I would resort to using an advanced formatting expression, something like this:

exiftool "-alldates<${filename;s/.*(\d{2})-(\d{2})-(\d{4}) at (\d{2})\.(\d{2}).*/$3:$2:$1 $4:$5:00/ or $_ = undef}" DIR

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

Jeneeben

Hello,

I need to change the creation date of some scans based on the file name.
The syntax of the filename is: YYYY_MM_XXX and YYYY_MM

I tried to adjust the provided command: exiftool '-datetimeoriginal<${filename;$_=substr($_,0,7)} 00:00:00'

But I am getting "No writable tags set from ..." warning message.

How can I change the command to be able to get the Date from my file name?

Thanks in advance,
Jeneeben

StarGeek

#21
A timestamp requires 14 numbers and if you give only the year and month, thats only 6 plus 6 more for the time portion.  You need to add a day to the command
Try
'-datetimeoriginal<${filename;$_=substr($_,0,7)} 01 00:00:00'
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jeneeben


kyber

 :) Worked for me! issues were in datetimeoriginal vs created

thank you phil