Extract date from filname, and insert as date taken to exif (if missing)

Started by CompleteNewb, May 21, 2023, 09:02:43 PM

Previous topic - Next topic

CompleteNewb

Pretty much as title states.

After bughunting why a certain program wasnt working exactly the way i expected it to now and again, I found out that some of my older iOS/iphone photos was missing "date taken" in windows. But not ALL photos had missing exif "date taken" data.

So my question is can exiftool help insert missing exif data (ONLY if its missing) based on filename. And keeping everything else exactly the same.

Filenames being in this format

20220521_210350230_iOS.png

the first part is 2022 05 21 (yyyy mm dd), no idea what second string is, probably time? But thats less important i guess.

I've tried googling, searching the forums etc, even a few youtube vids, im not a complete computer novice, but all the switches etc are really confusing me.

Or if someone can point me to a previous explanation/post that's "newb" friendly. That I simply didn't find.

Thanks for reading!

Edit:

Tried "-alldates<filename" on a few test files earlier, which failed to update the "Date Taken" in properties, until i stumbled over a post by the Moderator Stargeek

https://exiftool.org/forum/index.php?msg=65344

and exiftool "-PNG:CreationTime<FileCreateDate", which made it work! I thought it simply didnt work with the synteax!


So updating the question to, exiftool  -p -wm cg "-alldates<filename"

then afterwards, running "-PNG:CreationTime<FileCreateDate"

Should work in a sense it will only update files missing Date Taken etc? As  I dont want to mess anything up. something like 13 000 pics/vids so..

Phil Harvey

Quote from: CompleteNewb on May 21, 2023, 09:02:43 PMSo updating the question to, exiftool  -p -wm cg "-alldates<filename"

You need capital -P (not lower case) to preserve the filesystem date/times.

Quotethen afterwards, running "-PNG:CreationTime<FileCreateDate"

The first command shouldn't change FileCreateDate if you use -P, so I don't think this is doing what you want.  Maybe this:

exiftool -if "not $creationtime" "-creationtime<filename" -P DIR

Here I'm still using -P to preserve FileModifyDate and FileCreateDate, but you could change this to "-filecreatedate<filename" "-filemodifydate<filename" in the command to set these too.

You don't need to worry about messing things up because the original files will be preserved with an "_original" added to the name.  You can delete these later if everything goes well.

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