Batch copy across different metadata fields, with added fixed text

Started by AlanX, December 02, 2018, 07:29:10 AM

Previous topic - Next topic

AlanX

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

AlanX

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

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

Quote1. append to the target field data rather than overwrite it.

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

Quote2. only write to the target field if it is empty.

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

AlanX

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

Quote from: AlanX on December 05, 2018, 04:40:13 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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).