Hello! First of all, it's fantastic to know that there is a community based around ExifTool that volunteers to offer advice in their spare time. Thank you all in advance. I have seeked out this program to solve a specific problem with my photo collection, and I have almost nailed it down.
I have two sets of photos - HQ and LQ. Both have different folder structures inside. The first one, HQ, contains a smaller set of high quality pictures, and unfortunately some of them have incorrect DateTimeOriginal fields. The second set, LQ, is a larger set which contains many, if not all of the photos from HQ (they share the same filename) - in lower quality. On the flipside, all photos in LQ have the correct DateTimeOriginal metadata.
My goal: to create only one set, which would contain the highest available quality of each photo, AND correct metadata. My solution:
1. Recursively batch transfer the DateTimeOriginal tag from LQ to HQ, using the -tagsFromFile option in ExifTool.
2. Discard all photos in LQ which already exist in HQ - probably using an external program like Picasa for ease of comparison.
I have managed to figure out the command which almost does what I want for step 1:
exiftool -r -tagsFromFile LQ/%f.jpg -datetimeoriginal HQ
Alas, although this does seem to update the files in the target (HQ) folder recursively, it doesn't seek through the source (LQ) recursively and I can only get it to source metadata from a single folder without subfolders. I am almost certain LQ/%f.jpg is to blame, but what should I replace it with?
Any advice would be greatly appreciated!
[Edit: changed logic mistake in step 2]
You need to check out the %d variable under the -w (http://www.exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) option.
Test it to be sure, but I think you want to use LQ/%:1d%f.jpg. That will take the path in HQ (for example HQ/some/dir/) and remove the top part of the path, i.e. HQ, leaving the rest of the path to be insterted between LQ and the %f, which should be the full path to the matching file.
Thank you :) I think I understand what the command exiftool -r -tagsFromFile LQ/%:1d%f.jpg -datetimeoriginal HQ is supposed to do. However, this would work assuming that the corresponding photos in HQ and LQ share the same relative folder structure. Unfortunately, this is not the case. Therefore, I get the following result when testing:
D:.
├───HQ
│ │ photo 1.jpg
│ │ photo 2.jpg
│ │
│ └───HQsub
│ photo 3.jpg
│
└───LQ
│ photo 2.jpg
│ photo 3.jpg
│
└───LQsub
photo 1.jpg
D:\Zdjęcia\Test>exiftool -r -tagsFromFile LQ/%:1d%f.jpg -datetimeoriginal HQ
Warning: Error opening file - LQ/HQsub/photo 3.jpg
Warning: Error opening file - LQ/photo 1.jpg
2 directories scanned
1 image files updated
2 image files unchanged
As expected, only photo 2.jpg is updated, because the relative path is the same. I would need a solution where I can specify:
source/any-path-1/%f.jpg and destination/any-path-2/%.jpg, where any-path-1 and any-path-2 can be different, and include a different number of levels, but the %.jpg remains the same for both.
This will be painful. One way to tackle this is to move all of the HQ files into a common directory, then run ExifTool there, then move them back again. This can be done with two exiftool commands:
1. exiftool -r "-comment<directory" -directory=tmp HQ
2. exiftool -r -tagsFromFile @ -datetimeoriginal -srcfile tmp/%f.%e -tagsfromfile tmp/%f.%e "-directory<comment" -comment= LQ
The second command is quite tricky, and I don't have time to test it right now so I hope it works (run it on some test files first!). The commands will overwrite then delete any existing JPEG Comment, so you should use another tag to store the directory name if you use the Comment tag for something else. Also, the commands will leave behind files in the "tmp" directory if they don't have corresponding files in LQ. If this happens, you will have to run one more command to move them back again:
3. exiftool "-directory<comment" -comment= tmp
- Phil
Rather than move the files, wouldn't it be better just to copy them or even just link them? Then they could be discarded after use.
There you go, another use for the Hardlink tag. Make a test directory with an HQ and LQ directory inside. Link all the files into their respective directories. Run your first command on the test directories and then delete the test directories.
exiftool -r "-hardlink<TestDir/HQ/$filename" HQ
exiftool -r "-hardlink<TestDir/LQ/$filename" LQ
exiftool -r -tagsFromFile TestDir/LQ/%f.jpg -datetimeoriginal TestDir/HQ
Test it out first, of course. And make sure there aren't any duplicate names. I'm not sure what would happen there.
Ooooo. Hardlink. Nice. Great idea! You guys are so smart!!
But you don't need to hard link both sets of files. Just these two commands will do:
1. exiftool -r "-hardlink<tmp/$filename" LQ
2. exiftool -r -tagsfromfile tmp/%f.%e -datetimeoriginal HQ
If there are duplicate file names then the DateTimeOriginal from the first one linked from LQ will get written to all same-named files in HQ.
Afterwards, if everything went well you can delete the "tmp" directory and use this command to remove the "_original" backups:
exiftool -r -delete_original HQ
- Phil