ExifTool Forum

ExifTool => Newbies => Topic started by: Horns on December 11, 2023, 03:25:57 AM

Title: Ignoring characters at start of filename when changing dates.
Post by: Horns on December 11, 2023, 03:25:57 AM
Hi,

I'm trying to change the exif dates of a bunch of files based on the filename. I've tried using exiftool "-AllDates<Filename", but it gets tripped up by some digits that appear at the start of the filename - these are formatted eg 00097158-PHOTO-2023-09-24-17-43-57.jpg

Is there a way to ignore the first 8 characters in the filename when doing this?

Thanks!
Title: Re: Ignoring characters at start of filename when changing dates.
Post by: StarGeek on December 11, 2023, 08:55:11 AM
Try
exiftool "-AllDates<${Filename;s/^\d+//}" /path/to/files/

This uses Perl Regular Expressions (RegEx) to strip away all numbers from the start of the filename.

This command is for Windows CMD.  Change the double quotes into single quotes for Mac/Linux.
Title: Re: Ignoring characters at start of filename when changing dates.
Post by: Horns on December 11, 2023, 10:50:43 AM
That did the trick nicely, thanks!