I am relatively new to exitool and have limited knowledge in scripting. While updating (with realistic creation dates and keywords from a .csv file) a directory containing pictures scanned from negatives or slides, I have found a tag duplication problem affecting a large series of files. Typically, when batch processing the images, I get many messages such as :
Warning: Duplicate Orientation tag in IFD0 -
Investigating a few of the affected images with:
exiftool -a -G1 -H image.jpg
leads to:
[IFD0] 0x0112 Orientation : Horizontal (normal)
[IFD0] 0x0112 Orientation : Horizontal (normal)
I have found that using:
exiftool -ifd0:orientation= image.jpg
deletes both orientation tags, and using afterwards:
exiftool -ifd0:orientation=horizontal image.jpg
recreates a single correct tag. However I am wondering if this process could be automated in some way, such as detecting the duplicated tag, keeping track of the orientation, deleting the two tags, and recreating one with the saved parameter (horizontal or vertical) or any other method.
Unfortunately this must be done in two commands. However, you can combine them into one command line:
exiftool -ifd0:orientation= -execute -ifd0:orientation=horizontal -common_args image.jpg
- Phil
Thanks. I have finally been able to count the duplicated tags by using a command on a Mac such as:
exiftool -a -G1 -H Path_toFile | awk '/0x0112/,/0x0112/' | awk '/0x0112/{x+=1}END{print x}'
and when the tag number is >1, to extract the tag value in order to re-write it with your code, by another similar way:
exiftool -a -G1 -H path_to_file | grep 0x0112 | tail -n1 | cut -d: -f2 | cut -d ' ' -f2
The may not be the best way, but it works and I have wrapped this in a small Applescript. This is hopefully a one time job therefore speed is not critical.