How to set new date from filename + set dummy time?

Started by erodrigues, November 22, 2021, 11:52:22 AM

Previous topic - Next topic

erodrigues

Dear all,

Tried finding anypost with similar problem but failed :( so decided to ask for help

I am re-organizing some backed up photos and EXIFtool is helping me alot... :) now I have a problem I can't figure out how to fix:

I have been using:

exiftool '-CreateDate<FileName' '-ModifyDate<FileName' '-FileModifyDate<FileName' '-FileAccessDate<FileName' FILENAME


which work fine for files named, i.e.: 20180212_115657.jpg ....but for files without time i.e.: IMG-20180205-WA0060.jpg I get:

Warning: Minute '60' out of range 0..59 in File:FileModifyDate (ValueConvInv) - IMG-20180205-WA0060.jpg

I understand that this is because of the "WA0060" so I was wondering:

How can I use just the DATE of the filename but write a dummy time?

Thanks for any help
ER

StarGeek

You would match the 8 numbers that make up the date and add a static time to the end
exiftool '-CreateDate<${FileName;m/(\d{8})-wa/i;$_=$1} 00:00:00' /path/to/files/

example
C:\>exiftool -P -overwrite_original "-CreateDate<${FileName;m/(\d{8})-wa/i;$_=$1} 00:00:00" Y:\!temp\aa\IMG-20180205-WA0060.jpg
    1 image files updated

C:\Programs\>exiftool -g1 -a -s -CreateDate Y:\!temp\aa\IMG-20180205-WA0060.jpg
---- ExifIFD ----
CreateDate                      : 2018:02:05 00:00:00
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

erodrigues



Thank you so much for the quick reply, I was modifying my post when I got a BSOD :(

I was going to ask the solution so that besides writing the time as metadata, how can I use the same time to rename the file so that the file:

IMG-20180205-WA0060 ends up as "IMG-20180205-WA0060-hhmmss" or "IMG-20180205-WA-hhmmss"

Thanks again,
ER

StarGeek

As long as you know you aren't processing non-WhatsApp files, you could use
exiftool -Filename=%f-hhmmss.%e /path/to/files/
or
exiftool -Filename=%-.4f-hhmmss.%e /path/to/files/

You can find details on the % tokens under the -w (-TextOut) option.

If your files are from mixed sources, then a more complex command would be required.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

erodrigues

Thanks again! I really appreciate the help and I will give it a try :)

This will be used for a group of files coming from a WhatsApp backup which does not have any other EXIF info/metadata.

I will read more on the documentation. It is incredibly powerful but quite complex to take in  :o

ER

erodrigues

Quote from: StarGeek on November 22, 2021, 03:14:44 PM
As long as you know you aren't processing non-WhatsApp files, you could use
exiftool -Filename=%f-hhmmss.%e /path/to/files/
or
exiftool -Filename=%-.4f-hhmmss.%e /path/to/files/

You can find details on the % tokens under the -w (-TextOut) option.

If your files are from mixed sources, then a more complex command would be required.

Worked well but I forgot that I have photos with the same date so if I enter 010101 as value for hhmmss I end up with same filenames ...  :-[

I looked for examples in the forum and I found this one https://exiftool.org/forum/index.php?topic=13031.0 but I can't figure out how I could adapt to generate a random time that I could put in hhmmss

Hoping you can shed some light

Thanks a million again,
ER


StarGeek

Are you keeping the What's App numbered order or don't care if they're not in the original order?

The simplest thing to do would be to add a copy number with %-c.  Something like this will add a (dash)copy number at the end of the filename for any file that has a duplicate name
-Filename=%f-hhmmss%-c.%e
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

erodrigues

Quote from: StarGeek on November 22, 2021, 05:40:15 PM
Are you keeping the What's App numbered order or don't care if they're not in the original order?

The simplest thing to do would be to add a copy number with %-c.  Something like this will add a (dash)copy number at the end of the filename for any file that has a duplicate name
-Filename=%f-hhmmss%-c.%e

Thanks, I will also give this a try.

I can skip the numbering order, no major importance. The key is the day.

Although ending up with IMG-20140609-WA-hhmmss.jpg would be better for me, the other solution you also kindly provided IMG-20140609-WA0001-hhmmss.jpg is still very much OK!

Thank you again for the help,
ER

I will try