Hello,
Here is an interesting one, I red how we can use Exiftool to resolve duplicated tags but how about allowing duplicated tags but only return once if value on those duplicated tag are identical?
<XMP-xmpMM:ManifestReferenceFilePath>
<rdf:Bag>
<rdf:li>/Users/Desktop/TT/Games Title -2.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Games Title.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Games Title -2.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Games Title.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/024929 Chess_b.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/024929 Chess_b.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/024929 Chess_b.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/024929 Chess_b.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Ludo_text.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Pachesi_Pachisi-Peli_text.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Ludo_Pachisi_text.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/024929 Hand(chess).tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Image_Side.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Splash.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Image_Side.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Splash.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Image_Side.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Splash.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Image_FOP.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Classic bottom bar.psd</rdf:li>
<rdf:li>/Users/Desktop/TT/Splash.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Image_BOP.tif</rdf:li>
<rdf:li>/Users/Desktop/TT/Splash.tif</rdf:li>
</rdf:Bag>
</XMP-xmpMM:ManifestReferenceFilePath>
If I do exiftool -ManifestReferenceFilePath file.ai or ${ManifestReferenceFilePath;s/\\n/\n/g} in Batch it will return me all the value, note that some of those value are duplicated. I'm wondering if there's a way to resolve those duplication and only return the value once?
Thanks & Regards,
Jeno
Hi Jeno,
I assume you are using -sep "\\n" or something similar for ${ManifestReferenceFilePath;s/\\n/\n/g} to work.
On Mac/Unix, passing the output through the "uniq" utility could solve your problem:
exiftool -manifestreferencefilepath -X FILE | uniq
which will remove all adjacent duplicate lines from the output.
Or if you only want to do this with a few specific tags, you can create a user-defined tag to do what you want. Here is an example config file (https://exiftool.org/forum/index.php/topic,4540.msg21621.html#msg21621) that will do this for IPTC Keywords.
- Phil
Thanks Phil,
I realised I need to do a sort | sort before | uniq for it to work efficiently. Now the hard part is how do I "integrate" this into my Window Batch code?
exiftool -m -p "--FILE NAME--$/$FileName$/$/--DIRECTORY--$/$Directory$/$/--CREATOR TOOLS--$/$CreatorTool$/$/--LAST MODIFY DATE--$/$ModifyDate$/$/--LINKS--$/${ManifestReferenceFilePath;s/\\n/\n/g}$/$/--SEPARATIONS--$/${PlateNames;s/\\n/\n/g}$/$/--FONT NAME--$/${FontName;s/\\n/\n/g}$/$/--FONT FILE NAME--$/${FontFileName;s/\\n/\n/g}$/$/" -sep "\n" %inputs% -W+! %%d%%f.txt
Oh! By the way, only -ManifestReferenceFilePath need | sort and | uniq
Hi Jeno,
Ah. But you are using the -p option to format your output. For this, the "uniq" idea won't work, so you'll have to go with the user-defined tag instead.
- Phil
wow! hmmmm I will have some problem sorting this out as I'm very bad in coding :-[
The example I provided gives you almost exactly what you need. All that is required is to change the tag names.
Sorry I this sound stupid but I can't get the config file to load on the windows machine. I am also having some trouble reading the syntax, what tag names should I be changing?
Read the comments here (https://exiftool.org/config.html) about how to activate a config file.
You should change "MyKeywords" to whatever name you want, and "Keywords" to "ManifestReferenceFilePath".
Then the tag with the name you selected should give you a list with the duplicate entries removed.
- Phil
Thank you very much Phi! I finally got it after a lot of testing!
Save as .ExifTool_config
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
RemovedDuplicatedLinks => {
Require => 'ManifestReferenceFilePath',
ValueConv => q{
my @list = ref $val eq 'ARRAY' ? @$val : $val;
my ($item, %found, @rtn);
foreach $item (@list) {
$item =~ s/^\s+//; # remove leading white space
push @rtn, $item unless $found{$item};
$found{$item} = 1;
}
return \@rtn;
},
},
},
);
1; # end
After have the config file loaded than use RemovedDuplicatedLinks instead of ManifestReferenceFilePath in the command line.