I have scanned pictures in different folders by year. The pictures do not have "datetimeoriginal"; I want to use the folder name (which is the year) to set the year in datetimeoriginal. For the month and day, I will just use 01/01 -- because the pictures are old and I only know the year.
I came across this post, which almost got me where I need to be: https://exiftool.org/forum/index.php/topic,5172.msg24929.html#msg24929
I used this code:
exiftool "-datetimeoriginal<${directory;/(\d{4})/ ? $_=qq($1:01:01 00:00:00) : undef}" -overwrite_original
However, it seems to be trimming the directory too much so I only getting the upper level, which is the decade.
Pictures are stored as Pics/1950s/1951/
When I run the script, it sets the year as 1950 -- not 1951. I am stumped.
Close.
If you use /.*(\d{4})/ instead of /(\d{4})/, you should get the last 4-digit number in the directory name instead of the first. (".*" causes it to skip as much as possible before matching the rest of the expression.)
- Phil