Lightroom uses the pipe (|) symbol as the separator for hierarchical keywords. I would like to use a slash (/) instead. I updated the .ExifTool_config file by adding the following as the last composite tag:
# Microsoft Style Hierarchical Subject
MSHS => {
Require => 'HierarchicalSubject',
ValueConv => '$val =~ s/\|/\//g; $val',
},
I have an image (test.jpg) and issue the following commands with results included.
C:\Temp>exiftool -Subject test.jpg
Subject : Events|Activities|Soccer
C:\Temp>exiftool -HierarchicalSubject test.jpg
Hierarchical Subject : Events|Activities|Soccer
C:\Temp>exiftool -MSHS test.jpg
MSHS : Events/Activities/Soccer
C:\Temp>exiftool "-Subject<MSHS" test.jpg
1 image files updated
C:\Temp>exiftool -Subject test.jpg
Subject : Events|Activities|Soccer
C:\Temp>exiftool -HierarchicalSubject test.jpg
Hierarchical Subject : Events|Activities|Soccer
C:\Temp>exiftool -MSHS test.jpg
MSHS : Events/Activities/Soccer
I am struggling to understand how MSHS can return the correct value but why the assignment of that value fails. I know it's something simple, but for the life of me I can't figure it out.
I can clearly update the Subject tag given the following commands/results:
C:\Temp>exiftool "-Subject=Events/Activities/Soccer" test.jpg
1 image files updated
C:\Temp>exiftool "-Subject" test.jpg
Subject : Events/Activities/Soccer
Any insight would be appreciated very much.
Thanks!
The complication comes from the fact that HierarchicalSubject is a list-type tag, so you need to loop through all of the items in the list, something like this:
MSHS => {
Require => 'HierarchicalSubject',
ValueConv => q{
my @list = ref $val eq 'ARRAY' ? @$val : $val;
s/\|/\//g foreach @list;
return \@list;
},
},
- Phil
Thanks so much Phil! That worked perfectly.
Scott