Author Topic: Batch copy across different metadata fields, with added fixed text  (Read 383 times)

AlanX

  • Jr. Member
  • **
  • Posts: 13
Sorry, this probably a very basic question, but there's an awful lot of documentation to plough through before I can see if I can do this simple task.
I want to take the contents of the [Title] field, and the contents of the [Author] field, and write them to the [Caption] field with some fixed text in the form '[Title]', by [Author]. I want to do this as a batch job across all of the JPEGs in a folder. I'm not copying from one JPEG to another, just 'each to his own'. I appreciate that the field names might be slightly different in ExifTool, I am using the Photoshop names here.
If someone can point me at a command line to do this, I'd be most grateful. If I can do this, I will hone it further so as to only write if the target field is already empty, etc.
Many thanks.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #1 on: December 02, 2018, 09:15:04 AM »
Hi Alan,

The command would be something like this:

exiftool "-caption<'$title' by $author" DIR

But you will have to figure out what tag names to use.  See FAQ's 2 and 3 for help with this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #2 on: December 03, 2018, 06:38:55 AM »
Many thanks. Making some progress. But here's the most basic of questions! The output text, after running the command, flashes up on the screen, and promptly disappears. Is it saved 'somewhere'? Or can it be?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #3 on: December 03, 2018, 07:11:02 AM »
How are you running the command?  Try adding -k to the command.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #4 on: December 03, 2018, 12:59:21 PM »
Many thanks.
Slowly getting to grips with some of the syntax. Now trying to copy XPTitle and XPAuthor to Title and Author respectively. I'm trying
C:\Users\Alan\Desktop\exiftool -EXIF:XPTitle<$Title F:\ExifTool\gallery2
Tried it without the EXIF bit, and with ObjectName in place of Title.
Must be me!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #5 on: December 03, 2018, 01:05:00 PM »
You need quotes around any argument containing a "<" symbol:

C:\Users\Alan\Desktop\exiftool "-EXIF:XPTitle<$Title" F:\ExifTool\gallery2

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #6 on: December 03, 2018, 01:18:34 PM »
Phil
Thanks, but still no joy. I've scanned to see the data is in the XPTitle and XPAuthor fields. But it's just not showing in the target fields after running the command. It's telling me there are no writable tags set from my target file.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #7 on: December 03, 2018, 01:21:52 PM »
This command is copying to XPTitle from Title.  It will only work if Title exists.  Maybe you want to copy the other direction?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #8 on: December 03, 2018, 01:25:07 PM »
I trying to copy text from XPTitle to the Title field, and text from XPAuthor to the Creator field. I was trying to mimic the syntax for the other task I asked about, but clearly have got it wrong!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #9 on: December 03, 2018, 01:26:21 PM »
Hi Alan,

Try this:

C:\Users\Alan\Desktop\exiftool "-Title<XPTitle" "-Creator<XPAuthor" F:\ExifTool\gallery2

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #10 on: December 03, 2018, 01:43:21 PM »
How stupid of me - had it back to front!
Truly appreciate your help on this - ExifTool is going to be so useful in sorting out metadata errors from our camera club members (Steyning, West Sussex, UK).
Many thanks.

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #11 on: December 04, 2018, 02:32:36 PM »
Nearly there, but have a question on copying XPTitle to Title and XPAuthor to Creator.
I've decided to run the command as a bat file in the directory I'm working on - suits my way of working on different drives.
So the bat file contains C:\ExifTool\exiftool "-Title<XPTitle" "-Creator<XPAuthor" *.jpg
What I would like to do is possibly two options. 1. append to the target field data rather than overwrite it. and 2. only write to the target field if it is empty.
I've scanned through all the options, but can't see it. Would appreciate a hint on this!

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Batch copy across different metadata fields, with added fixed text
« Reply #12 on: December 04, 2018, 03:33:54 PM »
Quote
1. append to the target field data rather than overwrite it.

In your example, to append would be "-Title<$Title $XPTitle" "-Creator<$Creator $XPAuthor" .

Quote
2. only write to the target field if it is empty.

See the -wm (writemode) option.  You would probably want -wm cg.
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.

AlanX

  • Jr. Member
  • **
  • Posts: 13
Re: Batch copy across different metadata fields, with added fixed text
« Reply #13 on: December 05, 2018, 04:40:13 AM »
Many thanks again.
For append, I had to turn your suggested expression around to read "-Title<$XPTitle $Title" "-Creator<$XPAuthor $Creator", otherwise it was appending Title to XPTitle, etc. I wanted XPTitle appended to Title. Same for XPAuthor and Creator.
The XP fields do seem to have some nasty habits - sometimes copying from other fields when those fields are changed (eg in Bridge), and sometimes changing IPTC values when they are edited in Windows. I would avoid them like the plague, but have to extract from there when others use them.
The -wm cg works fine, though I still can't find the explanation in the docs!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Batch copy across different metadata fields, with added fixed text
« Reply #14 on: December 05, 2018, 07:10:18 AM »
The -wm cg works fine, though I still can't find the explanation in the docs!

Follow the link that StarGeek provided.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).