Hi
I want to write a command to cut the value from IPTC Creator: Website and paste the valueto Description
Also, I want to apply a logic that the Creator: Website value contain a specific string (say YouTube)
I dont think there are built-in options for this
How can I write a command for this need?
Your question is a bit light on the details. What does the tag currently look like and how do you want it to end up.
Currently, I have a bunch of photos with the following metatdata
Creator: Website = http://www.example.com/userid=1234567
Description = blank
I want to change the metadata into
Creator: Website = blank
Description = ID 1234567
Ok, so you want to take the trailing numbers from whatever your creator tag is?
exiftool -if "$TAG=~/\d+$$/" "-Description<${TAG;m/(\d+$)/;$_=$1}" -TAG= /path/to/files/
Replace TAG with the name of the tag you're copying from and blanking. I added an IF to make sure you don't remove data that might not have the trailing numbers.
Quote from: StarGeek on May 22, 2020, 12:40:29 PM
Ok, so you want to take the trailing numbers from whatever your creator tag is?
yes
Do you think exiftool is the best for this purpose?
I tried but cannot understand the code :
Quote from: StarGeek on May 22, 2020, 12:40:29 PM
exiftool -if "$TAG=~/\d+$$/" "-Description<${TAG;m/(\d+$)/;$_=$1}" -TAG= /path/to/files/
As I said, you need to replace "TAG" with the actual tag you want to copy from and blank. You need to figure out what that tag is.
Run this command to see all the tags in your file
exiftool -G1 -a -s /path/to/file/
exiftool has to create a new file
what can I do if I really need to edit and apply the desired change to the original file?
Quote from: PL2020 on June 06, 2020, 02:07:10 AM
exiftool has to create a new file
what can I do if I really need to edit and apply the desired change to the original file?
Add -overwrite_original to your command
(It is good practice to backup your originals and/or carefully test your commands if you do this)
omg
I thought exiftool didn't have an option with such effect (why didn't I saw this when I went through the list of exiftool option ...... strange)
thanks a lot
Exiftool always creates a new copy of the file. In the case of the Overwrite_Original option (https://exiftool.org/exiftool_pod.html#overwrite_original), it doesn't keep the backup file.
The edited file will also have the FileModifyDate changed to reflect the time of the edit. It can be avoided by adding the -P (preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve). But it should be noted that some backup software rely on that time stamp to tell if the file has been changed.
oh yes the -p option is what i'm looking for
are there fields that the -p option does not preserve?
That's
-P. Capital P. The lowercase p is the
-p (printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat).
Quote from: PL2020 on June 07, 2020, 07:03:45 AMare there fields that the -p option does not preserve?
Read the docs on the
-P (preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve) for full details.