A few months ago I was using ExifToolGUI's ExifTool Direct in Windows10 to place the folder name as the subject using:
-P "-overwrite_original" "-xmp:Subject<${directory;s/.*\/([^\/]*$)/$1/}"
But today I return to the program and now it returns "." in the subject instead of the folder name. I don't see why it would behave differently today. (I'm using the line that was still stored (predefined) in ExifToolGUI and haven't changed any ExifTool or ExifToolGUI settings, so I don't really know what to try.)
ExifTool Log:
======== ./IMG_20190110_163117.jpg
1 image files updated
<-END-
There's no special characters in my folder tree, simply:
E:\GooglePhotos-ToEXIF\TEST
E:\GooglePhotosToEXIF\TEST
E:\GooglePhotosToEXIF\AAA\TEST
Trying Phil's:
"-xmp:Subject<Event/${filename;$_ = /(\d{4}-\d{2} [^\/]*)/ ? $1 : undef}"
Returns log:
======== ./IMG_20190110_163117.jpg
Nothing changed in ./IMG_20190110_163117.jpg
0 image files updated
1 image files unchanged
Warning: [minor] Advanced formatting expression returned undef for 'filename' - ./IMG_20190110_163117.jpg
Warning: No writable tags set from ./IMG_20190110_163117.jpg
<-END-
[/pre]
REF:
https://exiftool.org/forum/index.php?topic=8714.0
https://exiftool.org/forum/index.php?topic=8928.0
Any ideas what is going wrong?
Directory is based upon the directory name you enter on the command line. If you CDed into the directory and used a dot for the directory name, it will return a dot.
I don't know why it would change in ExiftoolGUI unless you changed location of the GUI.
You have to either use a complete path on the command line or edit the command to use FilePath, which always gives the full path (including filename).
Thanks. Unfortunately that doesn't fix my problem:
-P "-overwrite_original" "-xmp:Subject<${filepath;s/.*\/([^\/]*$)/$1/}"
returns the filename only.
======== ./IMG_20190110_163120.jpg
1 image files updated
<-END-
-P "-overwrite_original" "-xmp:Subject<Event/${filepath;$_ = /(\d{4}-\d{2} [^\/]*)/ ? $1 : undef}"
======== ./IMG_20190110_163120.jpg
Nothing changed in ./IMG_20190110_163120.jpg
0 image files updated
1 image files unchanged
Warning: [minor] Advanced formatting expression returned undef for 'filepath' - ./IMG_20190110_163120.jpg
Warning: No writable tags set from ./IMG_20190110_163120.jpg
<-END-
I haven't moved or modified ExifToolGUI or ExifTool, but maybe I restored my computer at some point...
So, I extracted the origial zip for a clean ExifToolGUI "install" but the same "." results.
-P "-overwrite_original" "-xmp:Subject<filepath"
Returns "E:/GooglePhotosToEXIF/AAA/TEST/IMG_20190110_163117.jpg"
-P "-overwrite_original" "-xmp:Subject<directory"
Returns "."
And then trying exiftool (ver 12.2.1.0 & ver 12.2.5.0 downloaded today) in command line window:
(from E:\GooglePhotosToEXIF\AAA\TEST> i.e. using cd with full path, no . shortcuts for up/down)
exiftool -P "-overwrite_original" "-xmp:Subject<${filepath;s/.*\/([^\/]*$)/$1/}" *.*
Returns "E:/GooglePhotosToEXIF/AAA/TEST/IMG_20190110_163117.jpg"
exiftool -P "-overwrite_original" "-xmp:Subject<${directory;s/.*\/([^\/]*$)/$1/}" *.*
Returns "."
exiftool -P "-overwrite_original" "-xmp:Subject<Event/${filepath;$_ = /(\d{4}-\d{2} [^\/]*)/ ? $1 : undef}" *.*
Warning: [minor] Advanced formatting expression returned undef for 'filepath' - IMG_20190110_163117.jpg
Warning: No writable tags set from IMG_20190110_163117.jpg
0 image files updated
exiftool -P "-overwrite_original" "-xmp:Subject<Event/${directory;$_ = /(\d{4}-\d{2} [^\/]*)/ ? $1 : undef}" *.*
Warning: [minor] Advanced formatting expression returned undef for 'directory' - IMG_20190110_163117.jpg
Warning: No writable tags set from IMG_20190110_163117.jpg
0 image files updated
MY GOAL: Place the directory name in a field that Google Photos will read so that I can search on that folder name. I was placing the folder name in "xmp:subject" because OneDrive reads that but now I find that Google Photos does not, so I need to place in "xmp:description". I can copy the existing subject to description but I have many many more files to do before the Google Photos free storage ends on June 1. I will now test if GooglePhotos can pick up substrings from the full path. I'll place the folders in the top directory to shorten the path to only the names that I need.
Good news! I don't NEED to solve this problem, although I would still like to! Because Google Photos will parse the entire path and then I can search on any folder names in that path:
xmp:Description = E:/AABB/Classpiration/IMG_20190110_163117.jpg
Google Photos CAN find:
AABB
Classpiration
Google Photos CANNOT find:
AAB
Classpir
So, it parses into keywords based on the "/" character and won't pick up substrings.
But INITIALLY did NOT parse spaces. (trying nonsense word so that it's unique.)
xmp:Description = E:/AABB/Classpik ktion/IMG_20190111-WA0035.jpg
CAN find:
"Classpik ktion"
CANNOT find:
Classpik
ktion
But a few minutes later,
CAN find:
"Classpik"
"ktion"
Then CAN find:
Classpik
ktion
Did it LEARN from my searches or did it need more time to parse the data more? or?
CANNOT find:
kti
ktio
"ktio"
classpi
"classpi"
So, probably parses on spaces but not substrings.
Anyways, using quotes around folder names that contains spaces appears to make them easy to find, so my offline folder structure can be maintained in Google Photos.
Like StarGeek says, the regex could never match "." unless "." was being typed for the directory name.
If needing a regex to always match the parent-folder... "${filepath; tr|\\|/|; s|.*/([^/]+)/[^/]+$|$1|}"
The tr|\\|/| converts all \ into / just incase of using a filespec instead of a directory name on Windows.
The s|match|replace| matches parent-folder by (grouping) everything inbetween the last two "/" in $filepath.