Hello,
we need to replace a part of the value in UserContent, with another part, or just nothing to remove this part.
Could we please get an idea, how we can do this.
Thanks in advance.
cheers mike
First you need to figure out what tag is "UserContent" (see FAQ #3 (https://exiftool.org/faq.html#Q3)) as exiftool doesn't have a listing for a tag by that name.
Once you figure out the actual tag, then to remove it the command would be
exiftool -TAG= /path/to/files/
To replace a part, you would use
exiftool "-TAG<${TAG;s/SEARCH/REPLACE/g}" /path/to/files/
Hello,
thanks StarGeek.
This works fine exept one Character '|'
This character is not replaced.
Is this a special perl character?
What can i do?
I have to replace "| and a word".
Thanks for assistance.
cheers mike
The pipe character is a special character in regex. If you need to use any of these characters
. ^ $ * + - ? ( ) [ ] { } \ | — /
then you need to escape it with a backslash. So "| and a word" would become "\| and a word".
Thank you very much, StarGeek,
This is working fine.
So it's possible to append a value with following conditions:
1) append only if Tag already exists
2) append only if value to append not already exists.
Very flexible indeed.
Cheers mike
Quote from: mike1950r on February 05, 2022, 01:36:19 PM
1) append only if Tag already exists
exiftool "-TAG<$TAG more text" /path/to/files/Any file that doesn't already have the TAG will fail with a "No writable tags set" error, but you can ignore that
Quote2) append only if value to append not already exists.
A bit more complicated and you have to make sure it's unique, but you can use the
-if option (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR)
exiftool -if "not $TAG=~/more text/" "-TAG<$TAG more text" /path/to/files/An example of what I mean by unique. If the above command found a file with "more texture", then the "more text" would match and it would be skipped. This can be compensated by using a more exacting regular expression.
Hi StarGeek,
we use following with success:
exiftool -if $UserComment -UserComment<${UserComment;s/APPENDTEXT//g} APPENDTEXT ...
1) Append only if UserComment tag exists
2) Append only if APPENDTEXT not already exists
Works exellent.
cheers mike
Hi StarGeek,
does your command: -if "not $TAG=~/more text/" "
mean more text is not a part in the tag value, or does it mean it is not the tag value?
Also how can i use two if conditions?
-if $UserComment
and
-if "not $TAG=~/more text/" "
Cheers mike
You could do it like this:
-if "$usercomment and not $usercomment=~/more text/"
- Phil
Thanks Lot Phil,
Everything is really working fantasticly.
You are so helpful here in the forum,
also with the perl questions, which enables using the capabilities of exftool a lot.
This also works fine for removing a part of the tag value:
-if $usercomment and $usercomment=~/REMOVETEXT/ -UserComment<${UserComment;s/REMOVETEXT//g}
Thanks lot again.
Cheers mike