10 **notmuch** **tag** [options ...] +<*tag*>|-<*tag*> [--] <*search-term*> ...
12 **notmuch** **tag** **--batch** [--input=<*filename*>]
17 Add/remove tags for all messages matching the search terms.
19 See :any:`notmuch-search-terms(7)` for details of the supported syntax for
22 Tags prefixed by '+' are added while those prefixed by '-' are removed.
23 For each message, tag changes are applied in the order they appear on
26 The beginning of the search terms is recognized by the first argument
27 that begins with neither '+' nor '-'. Support for an initial search term
28 beginning with '+' or '-' is provided by allowing the user to specify a
29 "--" argument to separate the tags from the search terms.
31 **notmuch tag** updates the maildir flags according to tag changes if
32 the **maildir.synchronize\_flags** configuration option is enabled. See
33 :any:`notmuch-config(1)` for details.
35 Supported options for **tag** include
39 .. option:: --remove-all
41 Remove all tags from each message matching the search terms before
42 applying the tag changes appearing on the command line. This
43 means setting the tags of each message to the tags to be added. If
44 there are no tags to be added, the messages will have no tags.
48 Read batch tagging operations from a file (stdin by default).
49 This is more efficient than repeated **notmuch tag**
50 invocations. See `TAG FILE FORMAT <#tag_file_format>`__ below for
51 the input format. This option is not compatible with specifying
52 tagging on the command line.
54 .. option:: --input=<filename>
56 Read input from given file, instead of from stdin. Implies
62 The input must consist of lines of the format:
64 +<*tag*\ >\|-<*tag*\ > [...] [--] <*query*\ >
66 Each line is interpreted similarly to **notmuch tag** command line
67 arguments. The delimiter is one or more spaces ' '. Any characters in
68 <*tag*\ > **may** be hex-encoded with %NN where NN is the hexadecimal
69 value of the character. To hex-encode a character with a multi-byte
70 UTF-8 encoding, hex-encode each byte. Any spaces in <tag> **must** be
71 hex-encoded as %20. Any characters that are not part of <*tag*\ > **must
74 In the future tag:"tag with spaces" style quoting may be supported for
75 <*tag*\ > as well; for this reason all double quote characters in
76 <*tag*\ > **should** be hex-encoded.
78 The <*query*\ > should be quoted using Xapian boolean term quoting
79 rules: if a term contains whitespace or a close paren or starts with a
80 double quote, it must be enclosed in double quotes (not including any
81 prefix) and double quotes inside the term must be doubled (see below for
84 Leading and trailing space ' ' is ignored. Empty lines and lines
85 beginning with '#' are ignored.
90 The following shows a valid input to batch tagging. Note that only the
91 isolated '\*' acts as a wildcard. Also note the two different quotings
92 of the tag **space in tags**
97 +foo::bar%25 -- (One and Two) or (One and tag:winner)
98 +found::it -- tag:foo::bar%
99 # ignore this line and the next
101 +space%20in%20tags -- Two
102 # add tag '(tags)', among other stunts.
103 +crazy{ +(tags) +&are +#possible\ -- tag:"space in tags"
104 +match*crazy -- tag:crazy{
105 +some_tag -- id:"this is ""nauty)"""
111 :any:`notmuch-config(1)`,
112 :any:`notmuch-count(1)`,
113 :any:`notmuch-dump(1)`,
114 :any:`notmuch-hooks(5)`,
115 :any:`notmuch-insert(1)`,
116 :any:`notmuch-new(1)`,
117 :any:`notmuch-reply(1)`,
118 :any:`notmuch-restore(1)`,
119 :any:`notmuch-search(1)`,
120 :any:`notmuch-search-terms(7)`,
121 :any:`notmuch-show(1)`,