Dear Phil,
Thank you very much for sharing this great app with all of us!
Although I realize this is quite a powerful tool, I am not sure how to do what I need in this particular case, and I'd appreciate if you could help me out with the following situation:
I have many images copied to separate directories like this:
(taken on 2021.05.11, but copied on 2021.05.14)
2021.05.14 Short description 1/
img_1.jpg
img_2.jpg
img_3.jpg
(taken on 2021.07.12, but copied on 2021.07.18)
2021.07.18 Short description 2/
img_1.jpg
img_5.jpg
img_7.jpg
I would like to have those moved to a dir structure, based on their real creation date,
and to also keep the "Short description" parts in the destination directory names,
like this:
2021/2021.05/2021.05.11 Short description 1/
img_1.jpg
img_2.jpg
img_3.jpg
2021/2021.07/2021.07.12 Short description 2/
img_1.jpg
img_5.jpg
img_7.jpg
Is that possible and could you please share a command line that would do that transformation?
Thanks!
This command assumes that the Year/Year.Month/ part of the directory doesn't change and that the timestamp used is DateTimeOriginal. Also, you can't run it from the same directory as the files, you have to be at least 1 level up. For example, you can't CD into 2021/2021.07/2021.07.18/ and run it from there. You would have to be no deeper than 2021/2021.07/ and use 2021.07.18/ as the path. Though a complete path would be best
Try this. If the results look good, then change TestName to FileName
exiftool -d "%Y.%m.%d" "-Testname<%-:1d/$DateTimeOriginal ${Directory;m/\d{4}\.\d\d\.\d\d\s+([^\/]+$)/;$_=$1}/%F" /path/to/files/
Example output
C:\>exiftool -d "%Y.%m.%d" "-Testname<%-:1d/$DateTimeOriginal ${Directory;m/\d{4}\.\d\d\.\d\d\s+([^\/]+$)/;$_=$1}/%F" "Y:\!temp\2021\2021.05\2021.05.17 Short description 1\Test4.jpg"
'Y:/!temp/2021/2021.05/2021.05.17 Short description 1/Test4.jpg' --> 'Y:/!temp/2021/2021.05/2021.05.11 Short description 1/Test4.jpg'
0 image files updated
1 image files unchanged
If the Year or Year.Month part of the path might change, then that would require adjustments to the command.
Thanks, StarGeek! Works as you described...
By the way, what exactly is the idea behind the "%-:1d" (in: "-Testname<%-:1d/$DateTimeOriginal ${Directory;m/\d{4}\.\d\d\.\d\d\s+([^\/]+$)/;$_=$1}/%F")
Details can be found under the "Advanced features" section of the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut).
In this case, you start with %d, which represents the directory of the file being processed. The -:1 part does some editing on the directory path. The minus sign says to remove data from the end, the colon means remove full directory names (as opposed to a dot which would remove individual characters), and the 1 indicates only one level is to be removed. So the end result, given the example path of 2021/2021.05/2021.05.14 Short description 1/, it would remove the 2021.05.14 Short description 1 part of the path, which is then recreated using the correct data in the rest of the command.
This part is there just in case one of the files is currently in a directory that is a different month than indicated by the embedded data.
StarGeek is really a wizard with these tricky ExifTool commands.
Plus, his explanations really detailed and helpful.
:)
Some people do sudoku or crossword puzzles. Exiftool commands fulfill the same niche for me. :D
Oddly enough, I get that. :P