Author Topic: Combining two commands  (Read 211 times)

taconsta

  • Newbie
  • *
  • Posts: 3
Combining two commands
« on: February 24, 2019, 08:56:45 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Combining two commands
« Reply #1 on: February 24, 2019, 11:20:13 AM »
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
« Last Edit: February 24, 2019, 12:30:19 PM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2413
Re: Combining two commands
« Reply #2 on: February 24, 2019, 12:18:01 PM »
"-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
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Combining two commands
« Reply #3 on: February 24, 2019, 12:29:29 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

taconsta

  • Newbie
  • *
  • Posts: 3
Re: Combining two commands
« Reply #4 on: February 24, 2019, 02:34:58 PM »
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].

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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2413
Re: Combining two commands
« Reply #5 on: February 24, 2019, 05:30:35 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>
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Combining two commands
« Reply #6 on: February 24, 2019, 05:31:51 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

taconsta

  • Newbie
  • *
  • Posts: 3
Re: Combining two commands
« Reply #7 on: February 24, 2019, 05:54:28 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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2413
Re: Combining two commands
« Reply #8 on: February 24, 2019, 06:35:44 PM »
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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.