Combining two commands

Started by taconsta, February 24, 2019, 08:56:45 AM

Previous topic - Next topic

taconsta

Hello!

I am using FastPictureViewer (FPV) to rate my pictures and DXO and/or Zoner Photo Studio (ZPS) for further processing and organization.
FPV gives both a rating (numerical value between 1 and 5) and a rating percent in two EXIF fields in an XMP sidecar. If I later change the rating in ZPS or DXO, only the numerical value gets changed and then I get discordand values. So I have the following two commands, which each work fine:
Remove rating percent:
"C:\Windows\exiftool.exe" -overwrite_original  -xmp:RatingPercent= *.jpg *.xmp
Copy XMP sidecar -> XMP JPG
"C:\Windows\exiftool.exe" -overwrite_original -ext jpg -tagsfromfile %d%f.xmp *

They both work fine and provide the expected result. Since going through a lot of files takes time and I fully understand that having Exiftool parse the files instead of getting them offered by the system one by one, I'd like to combine both commands in one run, something like
"C:\Windows\exiftool.exe" -overwrite_original -xmp:RatingPercent= -tagsfromfile %d%f.xmp *.jpg *.xmp
just that it does not work (I still get the rating percent in both XMP and JPG files).

So, wise ExifTool-ers, what is the magical command?

Thanks,

Alex

Phil Harvey

#1
I would maybe suggest copying the FPV rating to the XMP:RatingPercent instead of just deleting.  You could do this:

"-xmp:ratingpercent<${rating;$_*=20}"

to convert a "Rating" (if that is the tag name) of 1-5 to a RatingPercent of 20-100.

Anyway, to answer your question.  You want to process both JPG and XMP, but only (I presume) copy the XMP tags to the JPEG.  So you should really use 2 separate commands, which can be combined into a single command line like this:

exiftool -overwrite_original -ext xmp "-xmp:ratingpercent<${rating;$_*=20}" -execute -tagsfromfile $d%f.xmp -all:all -ext jpg -common_args DIR

Also, I have added -all:all to copy only XMP tags from the XMP file directly to the same tags in the JPG file.

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

StarGeek

Quote from: Phil Harvey on February 24, 2019, 11:20:13 AM
"-xmp:ratingpercent,${rating;$_*=20}"

Shift key stop working?  I believe it should be
"-xmp:ratingpercent<${rating;$_*=20}"
and
exiftool -overwrite_original -ext xmp "-xmp:ratingpercent<${rating;$_*=20}" -execute -tagsfromfile $d%f.xmp -all:all -ext jpg -common_args DIR
* 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).

Phil Harvey

Quote from: StarGeek on February 24, 2019, 12:18:01 PM
Shift key stop working?  I believe it should be
"-xmp:ratingpercent<${rating;$_*=20}"

Haha.  Right.  Shift problem.  :P   I've edited my post to correct this.  Thanks.

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

taconsta

Quote from: Phil Harvey on February 24, 2019, 11:20:13 AM
I would maybe suggest copying the FPV rating to the XMP:RatingPercent instead of just deleting.

Thank you Phil for the quick answer in the first line!
No, I definitely don't want to take the percent over. Because if my wife (or I) re-rate the picture in one of the other two programs, only one value gets updated and then we get inconsistent values between rating and rating_percent (and then I'd have to reconcile them every time, since finally I use a batch function in FPV to move files around based on the ratings) [I'm sure ExifTool can do that as well, but I have different sets of rules which I can pick from a drop-down list].

Quote from: Phil Harvey on February 24, 2019, 11:20:13 AM
Anyway, to answer your question.  You want to process both JPG and XMP, but only (I presume) copy the XMP tags to the JPEG.  So you should really use 2 separate commands, which can be combined into a single command line like this:

exiftool -overwrite_original -ext xmp "-xmp:ratingpercent<${rating;$_*=20}" -execute -tagsfromfile $d%f.xmp -all:all -ext jpg -common_args DIR

Also, I have added -all:all to copy only XMP tags from the XMP file directly to the same tags in the JPG file.

- Phil

Ok, that was quite complicated, thank you for putting me on the right track.
I had though to apply two corrections:
1. it reads -tagsfromfile $%d%f.xmp
2. apparently there is the need for a second -overwrite_original flag somewhere after execute.

So, in case someone else will find the post useful, the final command working for me is:
exiftool -overwrite_original -ext xmp -xmp:ratingpercent= -execute -tagsfromfile %d%f.xmp -all:all -ext jpg -overwrite_original -common_args <DIR>

Again, thank you for the quick reply!

Alex

StarGeek

Quote from: taconsta on February 24, 2019, 02:34:58 PM
exiftool -overwrite_original -ext xmp -xmp:ratingpercent= -execute -tagsfromfile %d%f.xmp -all:all -ext jpg -overwrite_original -common_args <DIR>

I'd suggest move the -overwrite_original so it's part of the -Common_Args option
exiftool -ext xmp -xmp:ratingpercent= -execute -tagsfromfile %d%f.xmp -all:all -ext jpg -common_args -overwrite_original <DIR>
* 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).

Phil Harvey

Hi Alex/StarGeek,

Looks good.  Thanks for fixing my mistakes/oversights.

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

taconsta

Quote from: StarGeek on February 24, 2019, 05:30:35 PM
I'd suggest move the -overwrite_original so it's part of the -Common_Args option

Yeah, RTFM helps ;) and makes code more readable, manageable and predictable.

Thank you!

StarGeek

There's a lot of manual to read and it's taken years for me to get a grasp on some options.  And there's still a lot I have never used and don't have a lot of experience with.
* 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).