News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Moving values from one field to another

Started by PL2020, May 17, 2020, 05:55:28 AM

Previous topic - Next topic

PL2020

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?




StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

PL2020

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


StarGeek

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.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

PL2020

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/

StarGeek

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/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

PL2020

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?

greybeard

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)

PL2020

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

StarGeek

Exiftool always creates a new copy of the file.  In the case of the Overwrite_Original option, 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.  But it should be noted that some backup software rely on that time stamp to tell if the file has been changed.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

PL2020

oh yes the -p option is what i'm looking for

are there fields that the -p option does not preserve?

StarGeek

That's -P. Capital P.  The lowercase p is the -p (printFormat) option.

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 for full details.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).