ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: FraPe on October 02, 2014, 04:40:07 AM

Title: Wrong result / delimiter for filling XMP subject with parts of filename
Post by: FraPe on October 02, 2014, 04:40:07 AM
Dear Phil, dear Forum,

I want to use the filename of several JPG image files to populate XMP:Subject with keywords to use these as tags for image
applications (eg. Photo Mate R2 and F-Stop on Android tablet).

The filenames are in the form of (example): 0004_Wolayerseehof_dahinter_Mussen_2138m.jpg.
In this case I want to have subject populated with:
0004
Wolayerseehof
dahinter
Mussen
2138m
(Each filename part should be an own tag / subject).

To get this I used the following exiftool statement:
exiftool -overwrite_original "-xmp:subject<${filename; s/_/,\ /g; s/.jpg//}"

But what I get as ONE tag / subject:
0004, Wolayerseehof, dahinter, Mussen, 2138m

I also tried to use ';', '|' or '\n' instead of ',' but the result is the same, only one tag / subject.
I also tried it with the -addtagsfromfile option and the same "-xmp:subject<${filename; s/_/,\ /g; s/.jpg//}"
but also here I got the same result.

What is the right delimeter to make several tags / subject keywords instead of one tag / subject keyword including
the delimiter characters? Or is this approach basically wrong and I need another one?

Thank you in advance!

Kind regards, Franz Peter.
Title: Re: Wrong result / delimiter for filling XMP subject with parts of filename
Post by: Hayo Baan on October 02, 2014, 10:29:13 AM
List items are handled differently by exiftool and you normally need multiple -xmp:subject=... arguments. However, you can also instruct exiftool to automatically split your (well formed) input into separate items by making use of the -sep parameter.

In your case, use e.g.:
exiftool -overwrite_original -sep ", " "-xmp:subject<${filename; s/_/,\ /g; s/.jpg//}"

Hope this helps,
Hayo
Title: Re: Wrong result / delimiter for filling XMP subject with parts of filename
Post by: StarGeek on October 02, 2014, 01:52:41 PM
You could also just separate on the the underscore:

exiftool -overwrite_original -sep "_" "-xmp:subject<${filename;s/\.jpg//i}"

Title: Re: Wrong result / delimiter for filling XMP subject with parts of filename
Post by: FraPe on October 03, 2014, 01:38:43 AM
@Hayo Baan and StarGeek,

thank you very much.
That exactly is what I need!

And again: GREAT tool!   :D

Kind regards,
Franz Peter.