ExifTool Forum

ExifTool => Newbies => Topic started by: AlanX on December 02, 2018, 07:29:10 AM

Title: Batch copy across different metadata fields, with added fixed text
Post by: AlanX on December 02, 2018, 07:29:10 AM
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.
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey 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 (https://exiftool.org/faq.html#Q2) for help with this.

- Phil
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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?
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey on December 03, 2018, 07:11:02 AM
How are you running the command?  Try adding -k to the command.

- Phil
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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!
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey 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
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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.
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey 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
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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!
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey 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
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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.
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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!
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: StarGeek on December 04, 2018, 03:33:54 PM
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 (https://exiftool.org/exiftool_pod.html#wm-MODE--writeMode).  You would probably want -wm cg.
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: AlanX 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!
Title: Re: Batch copy across different metadata fields, with added fixed text
Post by: Phil Harvey on December 05, 2018, 07:10:18 AM
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