Main Menu

Writing Keywords

Started by irinaonline, June 20, 2017, 06:28:32 AM

Previous topic - Next topic

irinaonline

It seems, I have a bit of a problem with understanding, when I have to set correctly a ' or a " or a $ to point to a tag. Also it is a little bit unclear, when to use < and when =.

May you please help me to correct this command line, so that it works?

I am trying to write keywords and spaces or words without $ should be a text and all with leading $ should refer to a field.

-sep ", " -m "-Keywords=All,All Sync %ETV%,$CountryCode,$Country,$State,$City,$Location,$SupplementalCategories,$ISO,$Make $Model $BodySerialNumber,$Lens $MakeLensModel $LensSerialNumber,$ImageWidthx$ImageHeight,$FileType,f/$FNumber,$GPS:GPSAltitude $GPS:GPSAltitudeRef,$GPS:GPSLatitudeRef latitude,$GPS:GPSLongitudeRef longitude,Orientation $Orientation,Flash $Flash,Focal Length $FocalLength,$ShutterSpeed s,GPS Speed $GPS:GPSSpeed $GPS:GPSSpeedRef,Orientation $Orientation,Software $Software,Exif Version $ExifVersion,$Regionname"

As a plus it should check, if this tags are already written and only add them, if they are not there. I had no luck with NoDupe so far.

Thank you for your effort!

Phil Harvey

The "=" writes a literal string value to a tag.

The "<" copies (redirects) the values of other tags (which may be embedded in a string with leading "$" symbols).

On Windows, you need double quotes around the "<".  On Mac/Linux you must use single quotes around any "$" symbol.

And see FAQ 17 for how to prevent duplicate entries.

So your command would look something like this (on Windows):

-sep ", " -m -addtagsfromfile @ "-Keywords-<All,All Sync %ETV%,$CountryCode,$Country,$State,$City,$Location,$SupplementalCategories,$ISO,$Make $Model $BodySerialNumber,$Lens $MakeLensModel $LensSerialNumber,$ImageWidthx$ImageHeight,$FileType,f/$FNumber,$GPS:GPSAltitude $GPS:GPSAltitudeRef,$GPS:GPSLatitudeRef latitude,$GPS:GPSLongitudeRef longitude,Orientation $Orientation,Flash $Flash,Focal Length $FocalLength,$ShutterSpeed s,GPS Speed $GPS:GPSSpeed $GPS:GPSSpeedRef,Orientation $Orientation,Software $Software,Exif Version $ExifVersion,$Regionname" "-Keywords+<All,All Sync %ETV%,$CountryCode,$Country,$State,$City,$Location,$SupplementalCategories,$ISO,$Make $Model $BodySerialNumber,$Lens $MakeLensModel $LensSerialNumber,$ImageWidthx$ImageHeight,$FileType,f/$FNumber,$GPS:GPSAltitude $GPS:GPSAltitudeRef,$GPS:GPSLatitudeRef latitude,$GPS:GPSLongitudeRef longitude,Orientation $Orientation,Flash $Flash,Focal Length $FocalLength,$ShutterSpeed s,GPS Speed $GPS:GPSSpeed $GPS:GPSSpeedRef,Orientation $Orientation,Software $Software,Exif Version $ExifVersion,$Regionname"

Here I have had to specify -addTagsFromFile to be able to combine two copy operations on the same list-type tag.

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

irinaonline

perfect. thank you so much! it works :-)

irinaonline

and how can i write the year from datetimeoriginal in the format YYYY as a keyword?

Phil Harvey

add -d %Y to your command and use "$datetimeoriginal" in your string.

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

irinaonline

-d "%%Y%%m%%d %%H%%M%%S" is used in the same command to rename the file.

Phil Harvey

Then use ${datetimeoriginal#;s/:.*//} in your string.

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

irinaonline

Thank you! Is there a function like PROPER() which capitalizes the first character in each word of a string?

Phil Harvey

For an individual tag, you could do this in the string: ${TAG;s/\b([a-z])/\u$1/g}

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

irinaonline

that is a very easy to remember syntax.

may i ask you, how i could combine and's and or's?

how can i optimize this syntax (or that it works at all)?

-if "$Filename =~ /1S/i and ($SupplementalCategories =~ /R1102/i OR $SupplementalCategories =~ /R1170/i OR $SupplementalCategories =~ /R1103/i OR $SupplementalCategories =~ /R89052/i OR $SupplementalCategories =~ /R89110/i OR $SupplementalCategories =~ /R89129/i OR $SupplementalCategories =~ /R89130/i OR $SupplementalCategories =~ /R89145/i)"

StarGeek

I played around with your data and Regexp::Assemble and it comes up with
(?:R(?:89(?:1(?:[13]0|29|45)|052)|11(?:0[23]|70)))

So you could use
-if "$Filename =~ /1S/i and $SupplementalCategories =~ /(?:R(?:89(?:1(?:[13]0|29|45)|052)|11(?:0[23]|70)))/i"

Regex101 example
* 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).

irinaonline

i would love to understand this at some point, but this seems to pretty difficult or add new codes, as these were just examples and i need to add around 15 more job codes.

with the link you provided, a new regex will be created?

i added some codes, but the regex code did not update.

StarGeek

Quote from: irinaonline on June 20, 2017, 06:03:22 PM
i would love to understand this at some point, but this seems to pretty difficult or add new codes, as these were just examples and i need to add around 15 more job codes.

Yeah, it's would be very difficult to add new stuff to that.  That answer was compiled specifically for the data you gave.  As for understanding, if you follow the link, in the upper right it gives a step by step breakdown, but it requires you know something about RegEx first.

Quotewith the link you provided, a new regex will be created?

No, it just shows an example of what it matches.

If you want something that you can extend, try this:
-if "$Filename =~ /1S/i and $SupplementalCategories =~ /R1102|R1103|R1170|R89052|R89110|R89129|R89130|R89145/i"

To add more codes, add a pipe charcter | and then the new code.  For example, if your new code was R89177 then you would end up with
-if "$Filename =~ /1S/i and $SupplementalCategories =~ /R1102|R1103|R1170|R89052|R89110|R89129|R89130|R89145|R89177/i"
* 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).

irinaonline

this looks far better and easier to read and maintain. thank you very much for your time!