Multiple tag deletions

Started by DPUK01, June 26, 2025, 04:02:43 PM

Previous topic - Next topic

DPUK01

Hello. I want to
1. delete multiple tags in multiple jpg files located in the same folder. These are about 30 consecutive tags located in the XMP group and I don't want to delete the whole group. I could do this by first going the folder they are located in Terminal (I am using a Mac) and then use

Exiftool -[TAG]= -r *.jpg.

I could then go to the next tag and repeat this but is there any quicker way of doing this (perhaps by specifying the tag index number range)

2. I want to delete a group of tags in a different part of the metadata schema using

Exiftool -[group]:all= *.jpg

but add this to the above as a separate command to make a reusable set of commands

Any suggestions welcome

StarGeek

Quote from: DPUK01 on June 26, 2025, 04:02:43 PMHello. I want to
1. delete multiple tags in multiple jpg files located in the same folder. These are about 30 consecutive tags located in the XMP group and I don't want to delete the whole group.
...
I could then go to the next tag and repeat this but is there any quicker way of doing this (perhaps by specifying the tag index number range)

From the docs on the -TAG[+-^]=[VALUE] option
QuoteMany tag values may be assigned in a single command.

Deleting tags is simply a different type of assignment.

exiftool -TAG1= -TAG2= -TAG3= -TAG4= /path/to/files/

You can also use wildcards. For example, to remove all the GPS tags

exiftool -GPS*= /path/to/files/

You can mix individual tags and groups of tags

exiftool -TAG1= -TAG2= -TAG3= -TAG4= -GPS*= -XMP-xmpMM:all= /path/to/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

DPUK01

Thank you, Stargeek. The wildcard option sounds useful but I tried it and didn't get it to work. I ran

exiftool -History*= L1000161-2.jpg
zsh: no matches found: -History*=

There are several tags starting with that name in the XMP-XMPmm section

Am I doing something wrong here?

Phil Harvey

In all Unix shells you must protect the wildcards meant for ExifTool by quoting:

exiftool "-History*=" L1000161-2.jpg

StarGeek's command only works in Windows.

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

StarGeek

On Mac/Linux, options with asterisks need quotes, otherwise it looks for file that match that name

exiftool '-History*=' L1000161-2.jpg

Using -XMP-xmpMM:all= might also be an option for you, as the XMP-xmpMM group contains nothing but Media Management tags, which can bloat the file size by a lot. The one exception is PreservedFileName, which is usually used to hold the original filename before renaming.
"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

Phil Harvey

Ha.  Beat you by 18 seconds.  ;)
...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 ($).

StarGeek

Heh, I was debating on whether I should post my "Remove Doc History junk" command, typed up another paragraph, but then decided to delete it.

What the heck, I use this to delete the history/document stuff, but save the PreservedFileName tag

exiftool -P -overwrite_original -echo "Remove Doc History junk" -api "NoWarning+=No writable tags set from" -DocumentAncestors= -XMP-xmpMM:all= -TagsFromFile @ -PreservedFileName /path/to/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

DPUK01

Thank you, both of you. I didn't realise that about wildcards in Unix shells.

StarGeek, your "Remove Doc History junk" looks like it will work very well for what I want. Thanks again. I'll need to add -r for multiple files in a single directory (and maybe something else). I first want to compare the Exif metadata tags against those in the original file to see the changes. I started by pasting the results of each into Excel (afterwards realising that I could have created a .csv for each!) and then using a simple "IF=' comparison statement to see difference. However, then I saw that some tags have been re-ordered compared to the original so that won't work. Maybe I will investigate using the DIFF function in terminal. If you have any tips on using this or some other tool to compare tags in two files, then that would be great.

Phil Harvey

I haven't thought in detail about what you are trying to do, but the -diff feature isn't sensitive to the ordering of the tags, so it may be useful.

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

StarGeek

Quote from: DPUK01 on June 27, 2025, 06:05:26 AMHowever, then I saw that some tags have been re-ordered compared to the original so that won't work.

The reason for this is FAQ #13, Why is my file smaller after I use ExifTool to write information?
"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

DPUK01

Quote from: Phil Harvey on June 27, 2025, 06:31:28 AMI haven't thought in detail about what you are trying to do, but the -diff feature isn't sensitive to the ordering of the tags, so it may be useful.

- Phil

Thanks, Phil. I've started investigating the DIFF function by first creating two .json files for comparison:

exiftool -v L1000161-4.jpg >L1000161-4.json L1000161-5.jpg >L1000161-5.json

and then running

diff L1000161-4.json L1000161-5.json >difference_4_to_5.json

Then I can either view the two .json files in Xcode (although I am still searching how to view them side-by-side with synchronous scrolling) or view the difference .json file alone. (I tried to string the two lines together but got the 'Error: File is empty - L1000161-4.json' message and then realised that two files hadn't been created!). I will look at other ways of comparison, perhaps with html files instead.

DPUK01

Quote from: StarGeek on June 27, 2025, 11:12:59 AM
Quote from: DPUK01 on June 27, 2025, 06:05:26 AMHowever, then I saw that some tags have been re-ordered compared to the original so that won't work.

The reason for this is FAQ #13, Why is my file smaller after I use ExifTool to write information?


Thanks, Stargeek. That explains the re-ordering nicely.

Looking again at your

exiftool -P -overwrite_original -echo "Remove Doc History junk" -api "NoWarning+=No writable tags set from" -DocumentAncestors= -XMP-xmpMM:all= -TagsFromFile @ -PreservedFileName /path/to/files/

What is the -api option doing?



Phil Harvey

Quote from: DPUK01 on June 28, 2025, 12:26:13 PMexiftool -v L1000161-4.jpg >L1000161-4.json L1000161-5.jpg >L1000161-5.json

The command to display the metadata differences should be

exiftool L1000161-4.jpg -diff L1000161-5.jpg

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

StarGeek

Quote from: DPUK01 on June 28, 2025, 12:29:29 PMLooking again at your

exiftool -P -overwrite_original -echo "Remove Doc History junk" -api "NoWarning+=No writable tags set from" -DocumentAncestors= -XMP-xmpMM:all= -TagsFromFile @ -PreservedFileName /path/to/files/

What is the -api option doing?

The XMP-xmpMM:PreservedFileName is a tag I like to keep, as I use that to hold the original filename (e.g. DSC_0005.JPG) before I rename a file to year/month/date+ format. Just in case I screw something up badly, I can revert to the original names.

But not every file contains a PreservedFileName tag. For every one of those files, exiftool will give a No writable tags set from warning, which can end up being thousands of lines of output I don't care about.

The -api NoWarning option will suppress those warnings.
"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