Hi
for isolating hierachical keywords I use -xmp-lr:HierarchicalSubject to write to a text file. Afterwards I search and replace "," by ";" and "|" by " > ".
How can I do this during running exiftool and already write the replaced characters to the text file?
regards
Bernd
It sorta depends upon what you're doing with the text file. If you're just reading it, then you can do something like this:
exiftool -p "$filename ${HierarchicalSubject;tr/,\|/;>/}" >output.txt FilesOrDir.
That will output a list of filenames and their HierarchicalSubject. Not highly formatted, but quick and simple.
If you need to process the output with a script or something similar, then you're better off making a user defined tag, something like this:
MyHS=> {
Require => 'HierarchicalSubject',
ValueConv => q{
my $hs = join('; ',(ref $val ? @$val : ($val)));
$hs =~ tr/\|/>/;
return $hs;
},
},
Example output (HS is my shortcut for HierarchicalSubject, easier than typing the whole thing out every time):
c:/ exiftool -hs -myhs Z:\Pictures\Camera_Pictures\San_Diego_Zoo\2010-05-15\2010-05-14_12.58.08.Jpg
Hierarchical Subject : Animals|Marsupials|Koala, Settings|San Diego Zoo
My HS : Animals>Marsupials>Koala; Settings>San Diego Zoo
wow - the first quick and simple command works perfect! THX
one additional question - I would have to replace the "|" with " > " - there is a space character before and after the ">" - how does this work?
regards
Bernd
Instead of the simple tr/,\|/;>/ use the following tr/,/;/; s/\|/ > /g
tr/,/;/ will replace all occurrences of , with ;, s/\|/ > /g will substitute all | with " > ".
works perfect! THX
I only need a simple list with filename and the hierarchical keywords.
last question: how can I adopt the command to print only the filename without any extensions?
ie exiftool -p "$filename ${HierarchicalSubject;tr/,/;/; s/\|/ > /g}" >output.txt key.jpg
regards
Bernd
You could try something like this exiftool -p "${filename;s/\.[^.]+//} ${HierarchicalSubject;tr/,/;/; s/\|/ > /g}" >output.txt key.jpg
I tried to understand the used perl commands - got it, more or less ;-(
so, inserting "$/" within -p represents a newline - but how can I seperate the two fields with a tabulator?
I cannot find this option.
regards
Bernd
Hi Bernd,
You can put a tab directly in the -p argument -- it will come straight through in the output. The only problem would be if your shell intercepts the tab character, which is quite likely as it turns out. I don't have much time right now to think of a way around this, but I'll come back later with a solution.
- Phil
Edit: On a Mac, a tab is entered by pressing CTRL-V then TAB. I don't know about Windows.