Copy information from one field to another

Started by rwittich_de, October 03, 2020, 10:26:19 AM

Previous topic - Next topic

rwittich_de

Hello,

I am a new user of exiftool and I have a question:
I want to copy the information in the field "Sublocation" to the field "Description" in all jpg images in a folder. How can I do this?

Thanks for looking at my little problem

Reinhold

StarGeek

The basic command would be
exiftool "-Description<Sub-location" /path/to/files/

But make sure you check your data first with the command in FAQ #3 because you're asking to copy from an IPTC IIM/Legacy tag to an XMP IPTC Core tag.  It may be that you want to copy from Location, which is an IPTC Core tag, instead of Sub-location.

This command creates backup files.  Add -Overwrite_Original to suppress the creation of backup files.  Add -r to recurse into subdirectories. 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

rwittich_de

Thanks StarGeek,

this works perfect. What if I want to combine some fields like:

exiftool "-Description<Sublocation+City+Country" *.jpg

Is this ok?

Thanks

Reinhold

StarGeek

To include multiple tags and static data (such as spaces), you need to put a dollar sign in front of the tag names.
exiftool "-Description<$Sub-location $City $Country" /path/to/files/

If there is already a description and you want to add to that
exiftool "-Description<$Description $Sub-location $City $Country" /path/to/files/

This will fail, though, if Description doesn't already exist.  To cover the possibility that Description may or may not exist, you would use
exiftool "-Description<$Sub-location $City $Country" "-Description<$Description $Sub-location $City $Country" /path/to/files/

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

rwittich_de

Thanks again, StarGeek. I would never find by myself that the $ Sign is to add strings. I tried + and & but $ I would never try.
Now I have this:

exiftool "-Description<$Sub-location, $City, $Country"  *.jpg

This works in most cases, but if there is no city in the data, I get an error message. I would like to get a space or nothing. But it stops without adding the country. Is there a fix for that?

Thanks

Reinhold

StarGeek

Quote from: rwittich_de on October 03, 2020, 11:51:25 AM
Thanks again, StarGeek. I would never find by myself that the $ Sign is to add strings. I tried + and & but $ I would never try.

It's in the fourth paragraph under the -TagsFromFile option, which is what the "-TAG1<TAG2" construct is shorthand for.

If there's a chance that any one of the tags may be empty, it can get really messy. The basic rule is that any time a tag is assigned a value more than once, then the last assignment that can be executed will work.  So you could try this
exiftool "-Description<$Sub-location, $Country" "-Description<$Sub-location, $City, $Country" *.jpg

If City exists, than the second assignment will be executed.  If it doesn't exist, then the command will fall back to the first assignment.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

rwittich_de

Thanks again StarGeek. This workes perfect. I am very happy that I found this forum and I found such a great specialist like you.  If you like you can see the results of your help in a few days at my homepage www.wittich.com.
Many thanks and best wishes.
Reinhold

rwittich_de

Now I found another problem, I don't know if it comes from Exiftool. I have a string in descriprion, like street, city, country. That is perfect. If I upload it to my homepage and try to display it with Gmedia gallery, it is not visible. But if I change only one letter in this description it becomes visible. I do not understand this. What is the difference between a string generated by Exiftool and a string generated by me?
I hope some knows what to do.
Best wishes
Reinhold

rwittich_de

Found a fix:

exiftool -Overwrite_Original "-headline<$Sub-location, $Country." "-headline<$Sub-location, $City, $Country."  *.jpg

StarGeek

Another case of the interface using different names than the actual names of the tags.  If you run across any other problems along the same lines, you can download a test file with about 1,400 tags filled out from this thread.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype