Selectively re-write XMP field for only a certain filename pattern

Started by keiran.harris, March 23, 2021, 12:15:13 AM

Previous topic - Next topic

keiran.harris

Hi braintrust!

I have whats probably a newbie question that i cant quite make my logic in my head translate to a working command.

Im required to do something a little odd. Im in the process of bulk uploading my pics into googlePhotos, but hey-ho, seems they DONT (annoyingly) honour the XMP star rating field, to translate into "favourite" pics in google cloud. Ive used lightroom for a decade and my favourites are flagged as various star rating (1-5). Im happy to flatten them to just starred or not for the purposes of the google upload.

So my process is:
1/ use exif tool to find all these 'rated' pics (anything >=1 star)
2/ for these pics, rewrite the "make" EXIF field to something unique - im using "kphFAV" (you may correctly assume that this is a strange field to re-write - but my hands are tied on A/ what fields make it up to google, and B/ what i can search there on)
3/ upload all my pics (inc these restamped files) to googlePhotos
4/ find all "kphFAV" pics in google photos, and bulk mark as favourite from there.

^ this all works great, using the following switches:

exiftool -if '$rating ge "1"' -make="kphFAV" -overwrite_original -P  -r .

However, now i need to bake in another bit of decision logic that i cant figure out: i ONLY want it to apply this field re-stamp if the FILENAME matches a certain pattern. Specifically ending in: xxxxxxxxx-01.JPEG (these are my Lightroom exports for pics i have "developed" - ie post production tweaks).

Looking forward to getting an answer on this.
Massive props to the author of this tool. Wow, what a slice of your life you have dedicated to this. Amazing.

Thanks
Keiran.

Luuk2005

Greetings Keiran, you can try something like -if '$rating ge "1" and $filename =~ /xxxxxxxxx-01.JPEG$$/'
This to make sure the names end exactly like your description, but also you can use /i' at the end to make it case-insensitive.
Also, my Windows version needs $$ to say "end", but maybe yours is only needing one $ ????
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Phil Harvey

Quote from: Luuk2005 on March 23, 2021, 01:28:43 AM
Greetings Keiran, you can try something like -if '$rating ge "1" and $filename =~ /xxxxxxxxx-01.JPEG$$/'

This will match literal "x"s in the file name.  Just drop these if you only care about matching the end part of the file name.

QuoteAlso, my Windows version needs $$ to say "end", but maybe yours is only needing one $ ????

All versions are the same here.  A $/ in an ExifTool format string is used to represent a newline.  The -if argument is parsed as a format string like the -p option before being interpreted as a Perl expression.  This is mentioned in Note 3 of the -if documentation (perhaps it should be more prominently mentioned).

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

Alan Clifford

Could you start by downloading a favourite picture from google and examine the metadata with exiftool to determine what google is using as the favourite marker?  Or am I being too optimistic;  wrangling google is something I try to avoid.

StarGeek

Google doesn't alter the metadata of the file.  Let's see if I can copy/paste my data correctly.  This may be out of date as it's been awhile since I've checked.

The left column is the name that Google photos displays on the web page, the right is what tags are read to fill that data.










Google Photos nameTags read
DescriptionXMP-tiff:ImageDescription
XMP-dc:Description
IPTC:Caption-Abstract
Ducky:Comment
Date(Timezone in timestamp ignored in favor of GPS coord or local TZ)
IPTC:DateCreated+IPTC:TimeCreated
EXIF:DateTimeOriginal
XMP-photoshop:DateCreated
XMP-exif:DateTimeOriginal
IPTC:DigitalCreationDate+IPTC:DigitalCreationTime
EXIF:CreateDate
XMP-xmp:CreateDate
XMP-exif:DateTimeDigitized
EXIF:ModifyDate
XMP-xmp:ModifyDate
GPS:GPSDateStamp+GPS:GPSTimeStamp (adjusted for local timezone)
System:FileModifyDate
ModelEXIF:Model
XMP-tiff:Model
FNumberEXIF:FNumber
XMP-exif:FNumber
XMP-exif:ApertureValue
EXIF:MaxApertureValue
XMP-exif:MaxApertureValue
ExposureTimeEXIF:ExposureTime
XMP-exif:ExposureTime
EXIF:ShutterSpeedValue
XMP-exif:ShutterSpeedValue
FocalLengthEXIF:FocalLengthXMP-exif:FocalLength
ISOEXIF:ISO
XMP-exif:ISO
GPSLatitudeGPS:GPSLatitude + GPS:GPSLatitudeRef
GPSLongitudeGPS:GPSLongitude+GPS:GPSLongitudeRef
OrientationEXIF:Orientation
* 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).

Luuk2005

Greeting everyone! What is the [?code?] needed to quote another user's text? Does it require the javascript?
Also, what is the color that everyone is using with command lines, the closest Im getting so far is #a00000.

@ Phil Harvey: Im thinking the -if notes(3) description is probably well understood by most users.
For me though, I had to experiment, because logic was telling me that a final / must always be "EndRegex".
But now Im understanding: Exiftool's "format-string" conducts $/ before "perl" conducts /Regex$/.

Its hard for me to learn by words, so often going by notes made from experiments.. So when posting, going by -if notes like...
**NOTES about using $ inside /Regex/  (?WindowsVersion-only?)
    $$  == EOL      \$$  == Literal $
    ($) == EOL      \x24 == Literal $
But had no idea why $) could rescue $ from the $/ conversion, so a million thanks for clarifying!!
So now, the logic tells me that perl allows "newline" as "EndRegex", even if / was "BeginRegex"?

@ Keiran: Apologies for the xxxxxxxxx, its the autism often making me accept the explanations to be literal.
Sometimes I catch them, but hardly ever, because often making this same mistake, many times on other forums.
To be honest, the logic is still trying to tell me that you want it literal, but I know its not really true. 
Sorry for any misunderstandings, so the whole command should have been...
exiftool -if '$rating ge "1" and $filename =~ /-01.JPEG$$/' -make="kphFAV" -overwrite_original -P  -r .

Of course, this just me assuming that $Exif:Make can be read by "Google Photos", because you already tested it??
Im not know anything about "Google Photos", because never trusting anything with the name "Google" ever again.
But the experts is all here, and can definitely help which $Tags are best for writing, so that Google can read them. 
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

StarGeek

Quote from: Luuk2005 on March 23, 2021, 05:04:09 PM
Greeting everyone! What is the [?code?] needed to quote another user's text?

It's [quote][/quote].  Or select the text you want to quote and hit the button above the text box area.

QuoteAlso, what is the color that everyone is using with command lines,

As it says directly below the text box
    (Use [tt][/tt] for command line examples, and [code][/code] for sample exiftool output)

You can also select the text and click the button for [tt] and the for [code].

And for the upcoming question, [nobbc][/nobbc] to prevent BBCode processing.
* 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).

StarGeek

Quote from: Luuk2005 on March 23, 2021, 05:04:09 PM
Of course, this just me assuming that $Exif:Make can be read by "Google Photos", because you already tested it??

Hmmm... that slipped by me somehow.  I'll have to check but I'm guessing that Google Photos will read EXIF:Model and XMP-tiff:Model.
* 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).

Luuk2005

QuoteAnd for the upcoming question, [nobbc][/nobbc] to prevent BBCode processing.
You might be psychic, Im thinking its very good time to choose some lottery numbers!
Many thanks for the info.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

keiran.harris

Thank you everyone, what a fantastically helpful community, wrapped around an already really handy tool.

@Luuk2005 and @Phil - thanks for the ' and ' syntax inside of the -if, that's what I was missing, and yup, I would have likely stumbled through that end-of-string vs. end-of-line delimiters so thanks for flagging in advance. Im not too bad with regEx (.... and as an aside: @Luuk2005 thanks for being so helpful & friendly & also forthcoming with your condition - its an interesting insight for me into Autism about catching subtlety).

@stargeek - thats amazing data! it holds up against my (surface level) testing, but this gives me WAY more to work with should I need it.

@alan- good suggestion, but yeah, I've already tested a working process that is good for me... (re-write a field I don't care about that is also searchable in Gphotos - and yup @Luuk2005 all tested, and it works great)

As for google photos itself, having every photo I've EVER taken (about 90,000 at last count), accessible anywhere, well that's pretty nifty IMO.  I just have to beat the June 1st change of google storage plan rules :)

I plan to circle back on this today and confirm the logic before my bulk upload.
thanks again all, keep you posted.
K