Author Topic: Moving values from one field to another  (Read 390 times)

PL2020

  • Jr. Member
  • **
  • Posts: 17
Moving values from one field to another
« on: May 17, 2020, 05:55:28 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4458
Re: Moving values from one field to another
« Reply #1 on: May 17, 2020, 12:12:36 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

PL2020

  • Jr. Member
  • **
  • Posts: 17
Re: Moving values from one field to another
« Reply #2 on: May 22, 2020, 09:47:03 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4458
Re: Moving values from one field to another
« Reply #3 on: May 22, 2020, 12:40:29 PM »
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.

Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

PL2020

  • Jr. Member
  • **
  • Posts: 17
Re: Moving values from one field to another
« Reply #4 on: June 01, 2020, 10:42:04 AM »
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 :

exiftool -if "$TAG=~/\d+$$/" "-Description<${TAG;m/(\d+$)/;$_=$1}" -TAG= /path/to/files/

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4458
Re: Moving values from one field to another
« Reply #5 on: June 01, 2020, 11:36:51 AM »
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/
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

PL2020

  • Jr. Member
  • **
  • Posts: 17
Re: Moving values from one field to another
« Reply #6 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?

greybeard

  • Sr. Member
  • ****
  • Posts: 131
Re: Moving values from one field to another
« Reply #7 on: June 06, 2020, 02:46:38 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

  • Jr. Member
  • **
  • Posts: 17
Re: Moving values from one field to another
« Reply #8 on: June 06, 2020, 07:38:23 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4458
Re: Moving values from one field to another
« Reply #9 on: June 06, 2020, 11:30:15 AM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

PL2020

  • Jr. Member
  • **
  • Posts: 17
Re: Moving values from one field to another
« Reply #10 on: June 07, 2020, 07:03:45 AM »
oh yes the -p option is what i'm looking for

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

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4458
Re: Moving values from one field to another
« Reply #11 on: June 07, 2020, 11:40:03 AM »
That's -P. Capital P.  The lowercase p is the -p (printFormat) option.

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

Read the docs on the -P (preserve) option for full details.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.