Using an Args file to remove metadata block and preserve selected tags?

Started by Ad_Astra, February 14, 2025, 07:59:15 AM

Previous topic - Next topic

Ad_Astra

Hi

I have an args file to remove some metadata from jpeg files after exporting from Lightroom. I am trying to remove all the XMP-xmpMM tags except the PreservedFileName tag that I am very keen to retain.

My Args file has this line:

-XMP-xmpMM:all --xmpMM-PreservedFileName=
But this removes all the xmpMM tags including PreservedFileName. Tried various different methods but failed to retain PreservedFileName, any suggestions please as to what I am doing wrong?

greybeard

I think this extract from the documentation may help :

--TAG
Exclude specified tag from extracted information. Same as the -x option. Group names and wildcards are permitted as described above for -TAG. Once excluded from the output, a tag may not be re-included by a subsequent option. May also be used following a -tagsFromFile option to exclude tags from being copied (when redirecting to another tag, it is the source tag that should be excluded), or to exclude groups from being deleted when deleting all information (eg. -all= --exif:all deletes all but EXIF information). But note that this will not exclude individual tags from a group delete (unless a family 2 group is specified, see note 4 below). Instead, individual tags may be recovered using the -tagsFromFile option (eg. -all= -tagsfromfile @ -artist).


Something like this:

-XMP-xmpMM:all= -tagsfromfile @ -xmpMM-PreservedFileName

Phil Harvey

There must be one argument per line in an ARGFILE.  The line you used will give unexpected results.

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

greybeard

Quote from: Phil Harvey on February 14, 2025, 09:00:22 AMThere must be one argument per line in an ARGFILE.  The line you used will give unexpected results.

- Phil


Right - I missed that this was an arg file - and it does give very unexpected results.

(Although it does work on the command line without an arg file).

Is it possible to achieve what the OP asked for?

Phil Harvey

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

Ad_Astra

#5
I can see the following tags in the file:

Quote[XMP-xmpMM]     PreservedFileName               : Z81_5961
[XMP-xmpMM]     DocumentID                      : xmp.did:6d8b6d12-965f-1e42-bf32-7b04135a2fed
[XMP-xmpMM]     OriginalDocumentID              : 1C3269453669BACFED0D159C5E314B44
[XMP-xmpMM]     InstanceID                      : xmp.iid:6d8b6d12-965f-1e42-bf32-7b04135a2fed
[XMP-xmpMM]     DerivedFromDocumentID           : 1C3269453669BACFED0D159C5E314B44
[XMP-xmpMM]     DerivedFromOriginalDocumentID   : 1C3269453669BACFED0D159C5E314B44

But these lines in my arg file

-XMP-xmpMM:all=
-tagsfromfile XMP-xmpMM:PreservedFileName

fails with

QuoteInvalid TAG name: "tagsfromfile XMP-xmpMM:PreservedFileName"
Ignored superfluous tag name or invalid option: -tagsfromfile XMP-xmpMM:PreservedFileName

-XMP-xmpMM:all=
-tagsfromfile -XMP-xmpMM:PreservedFileName

fails with
QuoteInvalid TAG name: "tagsfromfile -XMP-xmpMM:PreservedFileName"
Ignored superfluous tag name or invalid option: -tagsfromfile -XMP-xmpMM:PreservedFileName

if I separate the args line into three lines:
-XMP-xmpMM:all=
-tagsfromfile
-XMP-xmpMM:PreservedFileName

still fails with this error message
QuoteInvalid TAG name: "tagsfromfile "
Ignored superfluous tag names or invalid options: -tagsfromfile  ...


Not sure what I am doing wrong.


StarGeek

Quote from: Ad_Astra on February 14, 2025, 10:05:16 AMBut these lines in my arg file

-XMP-xmpMM:all=
-tagsfromfile XMP-xmpMM:PreservedFileName

fails with


Invalid TAG name: "tagsfromfile XMP-xmpMM:PreservedFileName"
Ignored superfluous tag name or invalid option: -tagsfromfile XMP-xmpMM:PreservedFileName

This is FAQ #29, "My options don't work in a -@ ARGFILE". Because -tagsfromfile XMP-xmpMM:PreservedFileName is all on one line, exiftool is looking for a tag with that name, not the -TagsFromFile option. This breaks because tag names cannot have spaces in them.

Quote-XMP-xmpMM:all=
-tagsfromfile -XMP-xmpMM:PreservedFileName

fails with
Invalid TAG name: "tagsfromfile -XMP-xmpMM:PreservedFileName"
Ignored superfluous tag name or invalid option: -tagsfromfile -XMP-xmpMM:PreservedFileName

Same issue

Quoteif I separate the args line into three lines:
-XMP-xmpMM:all=
-tagsfromfile
-XMP-xmpMM:PreservedFileName

still fails with this error message
Invalid TAG name: "tagsfromfile "
Ignored superfluous tag names or invalid options: -tagsfromfile  ...

Getting closer. Note what is between the quotes. You have a trailing space, so exiftool is looking for a tag called "tagsfromfile " (trailing space included) and that fails for the same reason as above.

Now, the next problem that will pop up. The -TagsFromFile option requires the name of a file to copy the data from. In your command, you will be attempting to copy from a file called "-XMP-xmpMM:PreservedFileName".

Try this for your args file. Make sure there aren't any trailing spaces anywhere in the args file.
-XMP-xmpMM:all=
-tagsfromfile
@
-XMP-xmpMM:PreservedFileName
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ad_Astra

Thanks StarGeek

Your example worked perfectly, not sure what the @ symbol means I guess it is providing the filename?

StarGeek

Quote from: Ad_Astra on February 14, 2025, 11:42:03 AMYour example worked perfectly, not sure what the @ symbol means I guess it is providing the filename?

From the docs on the -TagsFromFile option
QuoteSRCFILE may be the same as FILE to move information around within a single file. In this case, @ may be used to represent the source file (ie. -tagsFromFile @), permitting this feature to be used for batch processing multiple files
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype