aboutsummaryrefslogtreecommitdiff
path: root/doc/git-annex-metadata.mdwn
blob: 7786d999b22cac446d354d9b7bc62167957a513c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# NAME

git-annex metadata - sets or gets metadata of a file

# SYNOPSIS

git annex metadata `[path ...]`

# DESCRIPTION

The content of an annexed file can have any number of metadata fields
attached to it to describe it. Each metadata field can in turn
have any number of values.

This command can be used to set metadata, or show the currently set
metadata.

When run without any -s or -t parameters, displays the current metadata.

Each metadata field has its own "field-lastchanged" metadata, which
contains the date the field was last changed. Unlike other metadata,
this cannot be directly modified by this command. It is updated
automatically.

# OPTIONS

* `-g field` / `--get field`

  Get the value(s) of a single field.

  The values will be output one per line, with no other output, so
  this is suitable for use in a script.

* `-s field=value` / `--set field=value`

  Set a field's value, removing any old values.

* `-s field+=value` / `--set field+=value`

  Add an additional value, preserving any old values.

* `-s field?=value` / `--set field?=value`

  Set a value, but only if the field does not already have a value set.

* `-s field-=value` / `--set field-=value`

  Remove a value from a field, leaving any other values that the field has
  set.

* `-r field` / `--remove field`

  Remove all current values of the field.

* `-t tag` / `--tag tag`

  Set a tag. Note that a tag is just a value of the "tag" field.

* `-u tag` / `--unset tag`

  Unset a tag.

* `--remove-all`

  Remove all metadata from the specified files.

  When a file is modified and the new version added, git-annex will copy
  over the metadata from the old version of the file. In situations where
  you don't want that copied metadata, you can use this option to remove
  it.

* `--force`

  By default, `git annex metadata` refuses to recursively set metadata
  throughout the files in a directory. This option enables such recursive
  setting.

* file matching options
 
  The [[git-annex-matching-options]](1)
  can be used to specify files to act on.

* `--all`

  Specify instead of a file to get/set metadata on all known keys.

* `--branch=ref`

  Specify instead of a file to get/set metadata on all files in the
  specified branch or treeish.

* `--unused`

  Specify instead of a file to get/set metadata on
  files found by last run of git-annex unused.

* `--key=keyname`

  Specify instead of a file to get/set metadata of the specified key.

* `--json`

  Enable JSON output (and input). Each line is a JSON object.

  The format of the JSON objects changed in git-annex version 6.20160726.

  Example of the new format:

	{"command":"metadata","file":"foo","key":"...","fields":{"author":["bar"],...},"note":"...","success":true}

  Example of the old format, which lacks the inner fields object:

	{"command":"metadata","file":"foo","key":"...","author":["bar"],...,"note":"...","success":true}

* `--json-error-messages`

  Messages that would normally be output to standard error are included in
  the json instead.

* `--batch`

  Enables batch mode, which can be used to both get, store, and unset
  metadata for multiple files or keys.

  Batch currently only supports JSON input. So, you must
  enable `--json` along with `--batch`.

  In batch mode, git-annex reads lines from stdin, which contain
  JSON objects. It replies to each input with an output JSON object.

  The format of the JSON sent to git-annex can be the same as the JSON that
  it outputs. Or, a simplified version. Only the "file" (or "key") field
  is actually necessary.

  For example, to get the current metadata of file foo:

	{"file":"foo"}

  To get the current metadata of the key k:
	
	{"key":"k"}

  Any metadata fields included in the JSON object will be stored,
  replacing whatever values the fields had before.
  To unset a field, include it with an empty list of values.

  To change the author of file foo to bar:

	{"file":"foo","fields":{"author":["bar"]}}

  To remove the author of file foo:

	{"file":"foo","fields":{"author":[]}}

# EXAMPLES

To set some tags on a file and also its author:

	git annex metadata annexscreencast.ogv -t video -t screencast -s author+=Alice

# SEE ALSO

[[git-annex]](1)

[[git-annex-view]](1)

# AUTHOR

Joey Hess <id@joeyh.name>

Warning: Automatically converted into a man page by mdwn2man. Edit with care.