How to WRITE filename AND some extra text into the image comment tag?

Started by artofit, December 27, 2014, 10:56:30 AM

Previous topic - Next topic

artofit

Hello,

I'm a newbie to Exiftool

To write some comment into the image comment tag:
exiftool -P -r -Comment="writing this in all jpg ext" *.jpg

To write the filenames into the comment tag:
exiftool -P -r "-Comment<filename" "F:\\Art\\out - Copie\\"

Why this creates new *.png, *.gif but not the comment tag?
OK for *.jpg and *.jpeg

Now how do you write the filename prefixed or suffixed with some text, aka "a common prefix"filename"a suffix"???
I tried with %f and %%f but couldn't make it work.

Thanks for clarifying.

P.S. Win 7 64bits, Exiftool 9.78
P.P.S. http://www.exiftool.org/exiftool_pod.html
Quote-TAG or --TAG                    Extract or exclude specified tag
  -TAG[+-]=[VALUE]                 Write new value for tag
  -TAG[+-]<=DATFILE                Write tag value from contents of file
  -TAG[+-]<SRCTAG                  Copy tag value (see -tagsFromFile)

For a newbie it's ambiguous, would you be so kind to develop

StarGeek

Quote from: artofit on December 27, 2014, 10:56:30 AM
Now how do you write the filename prefixed or suffixed with some text, aka "a common prefix"filename"a suffix"???

exiftool -P -r "-Comment<Prefix Comment ${filename} Suffix Comment"  FILE/DIR

Also, since you're using recursion, if you want to specify a certain file type like in your first command, you might want to look into the -ext option.
"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

artofit

Thanks
1/ Why the following produces gibberish, should be utf8 valid
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" *.jpg
same if I add -codedcharacterset=utf8

2/ above command updates 112 files, while
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" -ext .jpg
QuoteNo file specified

3/ On processing, how to prefix the original images, with "original_" instead of suffixing them?

StarGeek

Quote from: artofit on December 28, 2014, 10:56:46 PM
1/ Why the following produces gibberish, should be utf8 valid
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" *.jpg
same if I add -codedcharacterset=utf8
This is an area I always have problems with.  See FAQ 10 and FAQ 18 for some help.  I tried some options but was unable to get a useful result.

Quote2/ above command updates 112 files, while
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" -ext .jpg
QuoteNo file specified

In the first case, you specified *.jpg as the files to work on.  In the second case, you didn't actually specify a file or directory.  As it says under the -r option, you need to specify a directory for recursion to work.  If all the files you are working on are in the current directory, then you don't need the -r option.  But if you do have subdirectories you want to recurse into, you'll need to specify a directory to work on.  You could use a dot . to specify the current directory and then recursion would work. 

Quote3/ On processing, how to prefix the original images, with "original_" instead of suffixing them?

I don't think you can with a simple command.  You could rename the backups afterwards with exiftool or another renaming program, but depending upon how you do it, it would change or break the functionality of the -restore_original option.
"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

artofit

Quote1/ Why the following produces gibberish, should be utf8 valid
Code: [Select]
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" *.jpg
same if I add -codedcharacterset=utf8
This is an area I always have problems with.  See FAQ 10 and FAQ 18 for some help.  I tried some options but was unable to get a useful result.

Well, I observe two things:
1/ First if you rename some image file as "ёяшертыуиопющэъжьлкйчгфдсазхцвбнм.jpg"
exiftool can't process that image:
Quote1 files weren't updated due to errors

2/ XnConvert can set the Caption-Abstract as "ёяшертыуиопющэъжьлкйчгфдсазхцвбнм" and seems to use exiftool (at least in its bins)

Thanks

Hayo Baan

Quote from: artofit on December 28, 2014, 10:56:46 PM
Thanks
1/ Why the following produces gibberish, should be utf8 valid
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" *.jpg
same if I add -codedcharacterset=utf8

Works fine for me...
$ exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" ёяшертыуиопющэъжьлкйчгфдсазхцвбнм.jpg
    1 image files updated
$ exiftool -caption-abstract ёяшертыуиопющэъжьлкйчгфдсазхцвбнм.jpg
[IPTC]          Caption-Abstract                : àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»

Looks like it set exactly what you wanted (I am running this on a Mac though, not on Windows).

Quote from: artofit on December 28, 2014, 10:56:46 PM
2/ above command updates 112 files, while
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" -ext .jpg
QuoteNo file specified
Right, this looks like a bug in exiftool to me.

Quote from: artofit on December 28, 2014, 10:56:46 PM
3/ On processing, how to prefix the original images, with "original_" instead of suffixing them?
As Stargeek mentioned, you'll need to do this in a separate step. Something like this will probably do:
exiftool "-filename<${filename; s/(.*)_(original)/$2_$1/}" *.jpg_original

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

artofit

@Hayo Baan

As you have more experience with exiftool, did you report it as a bug.

I also tried to precede the command with:
CHCP 65001

To no avail

FYI: no issue with other cli tools such as ffmpeg

StarGeek

Quote from: Hayo Baan on December 30, 2014, 03:33:27 AM
Quote from: artofit on December 28, 2014, 10:56:46 PM
2/ above command updates 112 files, while
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" -ext .jpg
QuoteNo file specified
Right, this looks like a bug in exiftool to me.

Not a bug.  As the response indicates, there isn't a file or directory given to operate on.
"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

Hayo Baan

Quote from: StarGeek on January 01, 2015, 10:00:28 PM
Quote from: Hayo Baan on December 30, 2014, 03:33:27 AM
Quote from: artofit on December 28, 2014, 10:56:46 PM
2/ above command updates 112 files, while
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" -ext .jpg
QuoteNo file specified
Right, this looks like a bug in exiftool to me.

Not a bug.  As the response indicates, there isn't a file or directory given to operate on.

Doh, now why didn't I spot that...  ::)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I'm currently working on an update that will allow ExifTool to process files on Windows with Unicode characters in their names.  Look for this in ExifTool 9.79.

- 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 ($).

artofit

QuoteI'm currently working on an update that will allow ExifTool to process files on Windows with Unicode characters in their names.  Look for this in ExifTool 9.79.
Thanks, I just tried with ExifTool 9.80, but it does not seems to fix it:
exiftool -P -r -IPTC:Caption-Abstract="àäâéèêëïîöôóíùüû ES:áñ RU«ёяшертыуиопющэъжьлкйчгфдсазхцвбнм»" *.jpg
Output is still jibberish, and I'm warned:
Warning: Malformed UTF-8 character(s)

Phil Harvey

Your problem here is that the value you are trying to write is not valid UTF-8.  It has nothing to do with the filename problem.

But this command will ignore any files with Unicode names because wildcards don't yet work for this.  This is fixed by using "-ext jpg ." instead of "*.jpg", as I have always recommended.

- 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 ($).

artofit

QuoteBut this command will ignore any files with Unicode names because wildcards don't yet work for this.  This is fixed by using "-ext jpg ." instead of "*.jpg"
Ah ah. OK, but a warning/reminder for that would be nice.
Quoteas I have always recommended.
I'm still a fresh exiftool newbie :)

QuoteYour problem here is that the value you are trying to write is not valid UTF-8.
What do you mean?
Do you mean that my win7 console encoding is not in utf-8, but actually in another encoding, and therefore as exiftool expects an utf8 string it get messed up?
I even tried to force it before with chcp 65001, but to no avail. See
http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how/388500#388500

And why would it be so if other command tool are ok with these test characters?

What's the correct procedure than??

Thanks

Phil Harvey

I can't help much with teaching you how to use the Windows command shell.  But luckily you can avoid the problem by using a UTF-8 text editor and reading the arguments from an argfile instead.  See the -@ option for details.

- 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 ($).