Add bulk-tag script

This commit is contained in:
Alan Grainger
2026-10-19 17:51:53 +13:00
parent ac34a03482
commit 5140786e3d
7 changed files with 564 additions and 5 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ field is not shown and a name sent anyway is ignored.
The name is stored as a slug: lower case, letters and digits in any script, and a hyphen for anything else, at most 32
characters. A filename that already carries the prefix gets neither the prefix nor the name again. The name is the
visitor's own claim; IPP cannot check it. For what to do with it, see
[Find each visitor's uploads](/tag-and-review-uploads#find-each-visitors-uploads).
[Find each visitor's uploads](/tag-and-review-uploads#find-each-visitor-s-uploads).
### `fieldSeparator`
+48
View File
@@ -34,6 +34,8 @@ given is stored in the filename between the prefix and the original name, with a
- Search for `ipp_upload_jane-smith,` to see everything Jane sent.
- Add a workflow per visitor to tag or sort their uploads: **Filter by filename**, match type `startsWith`, pattern
`ipp_upload_jane-smith,`, then **Add Tags** with a tag such as `Uploaded/Jane Smith`.
- Tag every visitor's uploads at once, including past ones, with the
[bulk-tag script](#tag-every-visitor-s-uploads-at-once).
The comma matters: without it, `ipp_upload_jane` would also match `jane-smith` and `janet`. The name is whatever the
visitor typed, made lower case with hyphens for spaces and punctuation. A visitor who leaves the field empty is stored
@@ -55,6 +57,52 @@ goes on the end, an empty one is written empty, and a file with no fields at all
script that splits on the separator reads all of them: the last piece is the original filename, the rest are the
fields in order.
## Tag every visitor's uploads at once
A workflow acts only on new uploads, and you need one for each visitor. The upload image includes a script that tags
every upload with a visitor name, old and new, as `Uploaded/<name>`: `ipp_upload_jane-smith,IMG_0042.jpg` gets the
tag `Uploaded/jane-smith`.
1. In Immich, sign in as the user who owns the shares. The script sees only that user's photos.
2. Open **Account Settings**, then **API Keys**, and create a **New API Key** with the permissions `asset.read`,
`user.read`, `tag.create` and `tag.asset`.
3. Run the script in the upload container. Without `--apply` it changes nothing, and lists each file under the tag
it would get:
```bash
docker exec -e IMMICH_API_KEY=your-api-key ipp-upload node dist/tag-uploads.js
```
4. Check the list, then run it again with `--apply` to add the tags:
```bash
docker exec -e IMMICH_API_KEY=your-api-key ipp-upload node dist/tag-uploads.js --apply
```
5. Delete the API key in Immich if you don't plan to run the script again.
The API key reaches only that one command. The upload service itself still holds no key, as described in
[Why IPP marks the filename](#why-ipp-marks-the-filename-instead-of-tagging).
The script reads [`upload.filenamePrefix`](/config/upload-service#filenameprefix) and
[`upload.fieldSeparator`](/config/upload-service#fieldseparator) from the container's config. A second run adds only
the tags that are missing, so you can run it again after each event. Files without a visitor name, trashed files and
files of other users are left alone.
| Option | Default | Effect |
|-----------------------|-------------------------|-------------------------------------------------------------------------------------------|
| `--apply` | off | Add the tags. Without it, the script only reports. |
| `--parent <tag>` | `Uploaded` | The parent tag. `--parent "Guests/Wedding"` gives `Guests/Wedding/jane-smith`. |
| `--prefix <text>` | `upload.filenamePrefix` | The prefix to look for, when the files were stored with a different one. |
| `--separator <chars>` | `upload.fieldSeparator` | The separator to read, when the files were stored with a different one. Quote it: `'^'`. |
The script does not run when `upload.filenamePrefix` is `""`, because visitor uploads then look like any other photo.
Uploads from IPP 4.0.0 kept any comma in the visitor's filename, so `ipp_upload_Venice, Italy.jpg` looks as if it
has a visitor field. The script skips a file when the text before the separator is not a name IPP writes, or the
text after it starts with a space, and lists each file it skips. A 4.0.0 file named `ipp_upload_venice,italy.jpg`
still reads as a visitor called `venice`, so check the dry-run list before you use `--apply`.
## Review uploads before they appear
Immich has no approval queue for uploads through a shared link, but a workflow can move each upload into your
+1 -1
View File
@@ -49,7 +49,7 @@ What the owner sees in Immich:
[turned off](/config/upload-service#filenameprefix).
- The upload page asks for the visitor's name, optionally. A name given is stored in the filename after the prefix,
as `ipp_upload_jane-smith,IMG_0042.jpg`, so you can see who sent what and
[find each visitor's uploads](/tag-and-review-uploads#find-each-visitors-uploads). The field can be
[find each visitor's uploads](/tag-and-review-uploads#find-each-visitor-s-uploads). The field can be
[turned off](/config/upload-service#askname).
- The owner removes unwanted files in Immich, like any other photo.