I am still searching in the documentation and other posts, but is it possible to change the DateTimeOriginal based on the DIR? Reason is I had a camera a ways back that apparently had issues and kept resetting back to 2003. So... I now have about 2300 files like this. Luckily most are in individual DIR based on when I uploaded them. That is at least a start.
/2008/2008-06-29/100_3428.jpg 100_3428.jpg 2003:01:01 13:56:00
Any suggestions are greatly appreciated
Note: I cannot use Date/Time shift because ALL of the files have nearly the same DateTimeOriginal, CreateDate, and ModifyDate and all files in the DIR are random with date shifts. Simply shifting all by a # will not correct these. My only hope (I think) is the directory name.
Yes, this is certainly possible, but will be a bit tricky. One question is: How do you want to set the time part of DateTimeOriginal?
If you want to leave the time the same and just set the date, you could do this:
exiftool "-datetimeoriginal<${directory;s/.*\d{4}-\d{2}-\d{2}.*/$1:$2:$3/} ${datetimeoriginal;s/.* //}" -r DIR
- Phil
Setting the time part IMO will just have to be something I let not be 100% accurate. That's ok. As long as I can organize via Y/M I am good. What I was thinking is since I wouldn't want all files to have the same datetimeoriginal down to the second (would cause some confusion on my part with searches in other tools) I would like to have the time incremented by 1 second or 1 min. This way each file is unique to a degree. How could I accomplish this part?
Here is a post (https://exiftool.org/forum/index.php/topic,6253.msg30948.html#msg30948) that describes how this could be done.
- Phil
Quote from: Phil Harvey on May 28, 2015, 07:09:51 AM
Yes, this is certainly possible, but will be a bit tricky. One question is: How do you want to set the time part of DateTimeOriginal?
If you want to leave the time the same and just set the date, you could do this:
exiftool "-datetimeoriginal<${directory;s/.*\d{4}-\d{2}-\d{2}.*/$1:$2:$3/} ${datetimeoriginal;s/.* //}" -r DIR
- Phil
At first I couldn't figure this out. Played around with it for a while and made progress.
With the command above I got syntax errors because there was no space between the last d{2} and the . Fixed that and was good to a point. My directories were the next issue and had them setup as /YYYY/YYYY-MM-DD/. That really made things weird as you can imagine with how it wrote the DateTimeOriginal. I don't know regex or sed and spent quite a bit of time reading and testing with online test sites. My brain is fried now! :)
With syntax error
exiftool '-datetimeoriginal<${directory;s/.*\d{4}-\d{2}-\d{2}.*/$1:$2:$3/} ${datetimeoriginal;s/.* //}' /mnt/nano/photo_backup/tmp/2003-11-27/
Warning: Use of uninitialized value $3 in concatenation (.) or string for Directory - /mnt/nano/photo_backup/tmp/2003-11-27/100_3428.jpg
Warning: No writable tags set from /mnt/nano/photo_backup/tmp/2003-11-27/100_3428.jpg
1 directories scanned
0 image files updated
1 image files unchanged
No syntax error adding space after }
exiftool '-datetimeoriginal<${directory;s/.*\d{4}-\d{2}-\d{2} .*/$1:$2:$3/} ${datetimeoriginal;s/.* //}' /mnt/nano/photo_backup/tmp/2003-11-27/
1 directories scanned
1 image files updated
exiftool -datetimeoriginal 100_3428.jpg
Date/Time Original : 2003:11:27 13:56:00
exiftool -datetimeoriginal 100_3428.jpg_original
Date/Time Original : 2003:01:01 13:56:00
Thanks for the help! Learned quite a lot on this scenario! :D
Quote from: edif30 on May 29, 2015, 01:15:23 AM
With syntax error
exiftool '-datetimeoriginal<${directory;s/.*\d{4}-\d{2}-\d{2}.*/$1:$2:$3/} ${datetimeoriginal;s/.* //}' /mnt/nano/photo_backup/tmp/2003-11-27/
Warning: Use of uninitialized value $3 in concatenation (.)
Ah, sorry. I forgot to capture the matching numbers:
s/.*(\d{4})-(\d{2})-(\d{2}).*/$1:$2:$3/Adding the space caused the match to fail, so the substitution doesn't occur and the time will be based on the remaining digits in the file name.
- Phil