ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: aperturemode on August 17, 2023, 12:21:59 AM

Title: Non standard filename used to update exif alldates
Post by: aperturemode on August 17, 2023, 12:21:59 AM
This is a variation of FAQ 5 where the filename is used to update alldates:

exiftool "-alldates<filename" c:\images

However, my filename doesn't follow the requird formatting but looks as follows:

00003197-PHOTO-2018-05-16-18-36-11.jpg

where the data is in blue and time is orange. The problem is the 8 digit file identifier at the beginning of the filename. How can I manually update the exiftool command to allow for this?

Also, if this requires perl regex in the command, do you have a webpage reference that could be used to make further adjustments for other file formats?

Thank you.
Title: Re: Non standard filename used to update exif alldates
Post by: StarGeek on August 17, 2023, 12:47:03 AM
Try
exiftool "-alldates<${filename;s/^\d+//}" c:\images

This will strip away all the digits from the beginning of the file name before writing the date.

Quote from: aperturemode on August 17, 2023, 12:21:59 AMAlso, if this requires perl regex in the command, do you have a webpage reference that could be used to make further adjustments for other file formats?

There are a lot of tutorials out on the web.  The one I originally learned from is Regular-Expressions.info (https://www.regular-expressions.info/) which has info for Perl regex as well as other languages.

You can use a site like RegEx101 (https://regex101.com/) to test out your regular expressions.  It gives a break down of the regex in the upper right.

Most of my learning, though, came from doing a search on "Perl Regex" and what I wanted to accomplish.  The various StackExchange sites often come up at the top of the search. You can then copy paste what you find into Regex101 to learn more about what is actually happening.

That's also pretty much how I learned what I know of Perl.  Search what I wanted to do with "Perl" as part of the search and checked for what I could find on the StackExchange sites.
Title: Re: Non standard filename used to update exif alldates
Post by: aperturemode on August 17, 2023, 01:19:18 AM
Thank you very much StarGeek!

Regex is tricky but your references will help a lot. It's really fantastic to get that power and flexibility with ExifTool.