M: A quick command line loop for Linux to add a tag “xyz” to an image

G: Here’s a quick bash one-liner using exiftool to add a tag (keyword) xyz to all images in the current directory:

for img in *.jpg; do exiftool -overwrite_original -Keywords+=xyz "$img"; done

Notes:

If you want to process subdirectories too:

find . -iname '*.jpg' -exec exiftool -overwrite_original -Keywords+=xyz {} \;

Let me know if you want to tag a different metadata field (like Description, Title, etc.).

M: What about for multiple tags?

G: For multiple tags, you can just repeat the -Keywords+= option for each tag:

Single directory:

for img in *.jpg; do exiftool -overwrite_original -Keywords+=xyz -Keywords+=abc -Keywords+=123 "$img"; done

Recursive (all subdirectories):

find . -iname '*.jpg' -exec exiftool -overwrite_original -Keywords+=xyz -Keywords+=abc -Keywords+=123 {} \;

Key points:

If you want to batch-append the same set of tags to all files at once:

exiftool -overwrite_original -r -Keywords+=xyz -Keywords+=abc -Keywords+=123 .

This will process all images recursively starting from the current directory.

Let me know if you want to target a metadata field other than Keywords.

M: Is there another tag type besides keywords? And is there any way to add the tag without changing the last time the computer says it was modified?

G:

TL;DR:


Common Tag Fields Besides Keywords

Here are useful alternatives depending on what you want: | Field | Purpose | Example exiftool flag | |------------------|------------------------------------------|----------------------------------| | Subject | Often used for topics or categories | -Subject+=xyz | | Title | Short descriptive title | -Title="My Image" | | Description | Longer image description | -Description="Some text" | | ImageDescription | EXIF-specific description | -ImageDescription="Details" | | Comment | General comment | -Comment="Note here" | | TagsList | XMP tag list (can be more standardized) | -TagsList+=xyz |

Keywords vs. Subject:
Some programs (like Lightroom) use Keywords primarily, while others (like Windows Explorer) display Subject more prominently.


Preserve File Modification Time

By default, exiftool changes the filesystem modification timestamp.
To prevent that:

exiftool -P -overwrite_original -Keywords+=xyz filename.jpg

Full Loop Example:

for img in *.jpg; do exiftool -P -overwrite_original -Keywords+=xyz -Keywords+=abc "$img"; done

Explanation:


Quick Notes:

Let me know if you want to write the same tags to multiple metadata fields simultaneously.