Hi there,
I'm using Mylio Photos to facetag my images and then combine all legacy tags from XPKeywords with the PersonInImage tags into the IPTC Keywords.
It seems to work with the sequence of the following command lines. Anyone willing to review the below and advice on optimizing and/ or combining these in a single operation? I'm just a bit cautious to apply this to my full image database...
Copy XPKeyword tags to Keywords
-XPKeywords+>Keywords -sep ";" -P -r C:\Users\me\OneDrive\Documents\Myliotest
Copy facetags to Keywords
-Keywords+<PersonInImage -P -r C:\Users\me\OneDrive\Documents\Myliotest
Making sure all tags are separated (person names contain spaces, splitting names but maintaining the original strings as well)
-Keywords<Keywords -sep ";" -P -r C:\Users\me\OneDrive\Documents\Myliotest
-Keywords+<Keywords -sep " " -P -r C:\Users\me\OneDrive\Documents\Myliotest
Remove duplicates
-Keywords<${Keywords;NoDups(1)} -P -r C:\Users\me\OneDrive\Documents\Myliotest
Thanks in advance!
There's not much you can do to condense this because you are using two -sep option (https://exiftool.org/exiftool_pod.html#sep-STR--separator).
Try these commands
exiftool -P -r -sep ";" -api NoDups=1 "-Keywords+<XPKeywords" "-Keywords+<PersonInImage" "-Keywords+<Keywords"/path/to/files/
Here, I'm not sure if you actually want to use +< or not, as that will re-add all the separated keywords while keeping the original. So if your keywords was "John Smith", the result would be "John Smith, John, Smith". If you just want a result of "John, Smith", then use < without the plus sign.
exiftool -P -r -sep " " -api NoDups=1 "-Keywords+<Keywords" /path/to/files/
I haven't tested exactly how the -api NoDups option (https://exiftool.org/ExifTool.html#NoDups) works yet, so I don't know its limitations. You'll have to check to see if you have to run your last command or not.
StarGeek posted while I was composing my answer, but it isn't all in vain because for once I came up with an idea that StarGeek didn't consider... :)
First, your quoting is odd because most shells will require quotes around arguments containing "<" or ">".
I think you may be able to do everything you want with a single command. Here are the arguments in -@ ARGFILE syntax:
-addtagsfromfile
@
-Keywords-<XPKeywords
-Keywords+<XPKeywords
-Keywords-<PersonInImage
-Keywords+<PersonInImage
-Keywords-<${PersonInImage;tr/ /;/}
-Keywords+<${PersonInImage;tr/ /;/}
-sep
;
This will split PersonInImage on semicolons as well as spaces.
The -addtagsfromfile is necessary to prevent subsequent copy operations from overriding previous queued values.
Here is how it works for me using the above argfile named "a.args":
> exiftool a.jpg -keywords -xpkeywords -personinimage
Keywords : original 1, original 2
XP Keywords : this that;the other
Person In Image : phil harvey
> exiftool a.jpg -@ a.args
1 image files updated
> exiftool a.jpg -keywords
Keywords : original 1, original 2, this that, the other, phil harvey, phil, harvey
- Phil
OK, small fix:
-addtagsfromfile
@
-IPTC:Keywords-<XPKeywords
-IPTC:Keywords+<XPKeywords
-IPTC:Keywords-<PersonInImage
-IPTC:Keywords+<PersonInImage
-IPTC:Keywords-<${PersonInImage@;tr/ /;/ or $_=undef}
-IPTC:Keywords+<${PersonInImage@;tr/ /;/ or $_=undef}
-sep
;
The original version would duplicate single-word PersonInImage values, and this version fixes that.
The reason is that the -= syntax apparently doesn't remove matching values from those already queued to be written. Maybe it should, but I won't think about changing the behaviour at this point.
- Phil
Works for me, thanks both!
Again, works like a charm. Any chance I could limit the operation to updated/ changed files?
Quote from: Sieb on November 05, 2023, 09:55:24 AMAny chance I could limit the operation to updated/ changed files?
If you keep track of the last time you ran the command, you could compare to the
FileModifyDate. For example, if the last time you ran the command was on the November 1st
exiftool -if "$FileModifyDate gt '2023:11:01' " ...rest of commandHowever, this will not work if you use the
-P (
-preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve) as you do in your first post.
If you are on Windows, you could unset the Archive attribute with this command. The
/s option is for recurse. Remove it if you don't want to remove the Archive attribute in subdirectories.
attrib -A /s /path/to/files/*Once the Archive attribute is removed, any change to the file will automatically set the attribute. You could then use this to check only the files that have been changed
exiftool -if "$FileAttributes=~/Archive/" ...restofcommandExample. The file starts of with Archive set, indicating it has been changed. The
attrib command is run and Archive is no longer set. The exiftool checks to see if this file needs to be updated, but since there hasn't been any changes and Archive is not set, the file is skipped. Exiftool is run to change the
DateTimeOriginal. The file then shows that it has been altered.
C:\>exiftool -G1 -a -s -FileAttributes y:\!temp\Test4.jpg
[System] FileAttributes : Regular; (none); Archive
C:\>attrib -A /s y:\!temp\Test4.jpg
C:\>exiftool -G1 -a -s -FileAttributes y:\!temp\Test4.jpg
[System] FileAttributes : Regular; (none); Normal
C:\>exiftool -P -overwrite_original -if "$FileAttributes=~/Archive/" -DateTimeOriginal=now y:\!temp\Test4.jpg
1 files failed condition
C:\>exiftool -P -overwrite_original -DateTimeOriginal=now y:\!temp\Test4.jpg
1 image files updated
C:\>exiftool -G1 -a -s -FileAttributes y:\!temp\Test4.jpg
[System] FileAttributes : Regular; (none); Archive
Important: Any backup program you run may be dependent upon the Archive attribute. If you unset it, then the backup program might skip that during your next backup.
Quote from: Phil Harvey on November 04, 2023, 01:56:52 PMStarGeek posted while I was composing my answer, but it isn't all in vain because for once I came up with an idea that StarGeek didn't consider... :)
And added to my notes. I really need to organize them in some way.