[Originally posted by andre2p on 2008-10-05 15:21:41-07]
Can Exiftool be used to convert keywords that contain slashes (/) to using a period instead?
Example: IPTC keywords: Family/Dad; Places/Parks/Yosemite to Family.Dad; Places.Parks.Yosemite
I am trying to export photos to Photoshop Elements, and my keywords are not getting imported because of the slashes.
Thanks!
AC
[Originally posted by exiftool on 2008-10-05 18:23:33-07]You can do any sort of value manipulations that you want with
user-defined tags. The following config file will do what you
are looking for:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
NewKeywords => {
Require => 'Keywords',
ValueConv => q{
my @list = ref $val eq 'ARRAY' ? @$val : ($val);
tr{/}{.} foreach @list;
return \@list;
}
},
}
);
And use this command line to fix your keywords (where
FILE is one or more files or directory names):
exiftool "-keywords<newkeywords" FILE
Read the
config
file documentation for details on how to install a config file.
I hope this helps.
- Phil
[Originally posted by janott on 2008-10-09 19:37:14-07]Hi Phil,
I would like to do the same thing as the OP, only the other way round: I need to replace the dots used as IPTC keyword separators by slashes (for migration to another program).
So I tried using your config file with only dot and slash changing places in the following line:
tr{.}{/} foreach @list;
When entering
exiftool "-keywords<newkeywords" path/file
I get the following error message:
Can't use string ("Keywords") as a HASH ref while "strict refs" in use at /usr/share/perl5/Image/ExifTool.pm line 1344, <EXIFTOOL_FILE> line 7.
What went wrong?
Thanks
Jan
[Originally posted by exiftool on 2008-10-09 20:29:17-07]
Hi Jan,
My guess is that you're using a really old version of exiftool.
This should work with 7.00 or later.
- Phil
[Originally posted by janott on 2008-10-09 20:55:13-07]
Thanks, Phil,
you guessed right. I used 6.90, with the actual version it works fine.
Can I use this method as well to replace not only single characters, but also longer strings?
Jan
[Originally posted by exiftool on 2008-10-09 23:15:15-07]If you change "tr" to "s" then you can replace longer strings:
tr = translate (a character at a time)
s = substitute (whole strings)
The only trick is that the substitutions take a regular expression, so
some characters have special meanings ( . * ? + brackets etc) and must be
escaped with a backslash.
If you want to learn more, check the Perl docs.

- Phil