Hello,
I have a lot of scanned photos with a filename like "YYYYMMDD description".jpg.
Now I want to update the date fields, to have a better overview in for example digicam.
So far I'm able to do:
exiftool -overwrite_original "-datetimeoriginal<filename" "-filecreatedate<filename" "-filemodifydate<filename" <foldername>
Which works fine.
But some files are named "YYYYMM00 description".jpg, because the exact date was unknown.
I want to achieve something like replace(substring(filename,7,2),"00","01") but I can't figure it out.
Thanks in advance for your help,
Aloys
Is this what you want?:
exiftool -overwrite_original "-datetimeoriginal<filename" "-filecreatedate<filename" "-filemodifydate<filename" -api "filter=s/^(\d{6})00/${1}01/" <foldername>
Here I use the -api filter option to affect all extracted tags because you are only using FileName. This avoids having to duplicate the expression for each copy. If the file name doesn't match the search expression (ie. doesn't start with 6 digits then "00"), then the filter will do nothing.
- Phil
Hello Phil,
This is indeed what I was looking for, it works perfectly.
Result of a DIR command on some samples:
25-02-1987 19870225 Inge03.jpg
20-03-1987 19870320 Inges 2e verjaardag 04.jpg
01-07-1987 19870700 Inge drinkt uit bidon 01.jpg
01-07-1987 19870700 Inge drinkt uit bidon 02.jpg
16-03-1989 19890316 Aafke en Inge aan de wasbak 03.jpg
20-03-1989 19890320 Inge's verjaardag - 4 jaar - 09.jpg
12-11-2021 test.cmd
So again thank you very much!
I'm also going to delve into the Perl syntax, that's the missing link for me. :)
Kind regards,
Aloys
Hello Phil,
After some tests, there were still some files that were problematic mainly because of 'time'.
I did some research myself and finally came up with:
exiftool -overwrite_original "-datetimeoriginal<${filename;substr(1,8)}000000" "-filecreatedate<${filename;substr(1,8)}000000" "-filemodifydate<${filename;substr(1,8)}000000" -api "filter=s/^(\d{6})00/${1}01/" %Path%
So far, this has achieved the desired result.
Do you agree with this approach?
Or can this be combined with the filter.
Again thanks a lot.
Kind regards,
Aloys
Hi Aloys,
I don't know what you are trying to do, but the substr you added isn't doing anything at all because it isn't modifying $_. Also, the syntax is wrong (substr takes 3 arguments, the first should be the value $_).
But adding the trailing zeros is a good idea to fill in empty HH:MM:SS fields.
- Phil
Hi Phil,
What i tried to do is, getting (only) the first 8 characters of the filename and add the zeros, indeed to fill in the HH:MM:SS fields
But i struggle with the synax :)
I found the substr method who 'normaly' needs 3 arguments.
And I found advanced formatting feature, ${TAG;EXPR} and hoped to combine it like this.
But in the end I try something, because I don't understand the syntax enough.
What do you suggest?
Aloys
To get only the first 8 characters of the filename, try this:
exiftool -overwrite_original "-datetimeoriginal<filename" "-filecreatedate<filename" "-filemodifydate<filename" -api "filter=s/^(\d{6})00/${1}01/;s/(.{8}).*/$1/;$_.='000000'" %Path%
- Phil
Thank you Phil, works perfectly!