aboutsummaryrefslogtreecommitdiff
path: root/doc/tips/automatically_adding_metadata.mdwn
blob: b3118a75ed53820052d0bc359e9bed601d55c780 (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
git-annex's [[metadata]] works best when files have a lot of useful
metadata attached to them.

To make git-annex automatically set the year and month when adding files,
run: `git config annex.genmetadata true`

## git commit hook

A git commit hook can be set up to extract lots of metadata from files
like photos, mp3s, etc. Whenever annexed files are committed, their
metadata will be extracted and stored.

Download [[pre-commit-annex]] and install it in your git-annex repository
as `.git/hooks/pre-commit-annex`  
Remember to make the script executable! `chmod +x .git/hooks/pre-commit-annex`

### using extract

The git commit hook can use extract to get metadata.

Install it from <http://www.gnu.org/software/libextractor/>  
`apt-get install extract`

Configure which metadata fields to ask extract for: `git config metadata.extract "artist album title camera_make video_dimensions"`

To get a list of all possible fields, run: `extract -L | sed 's/ /_/g'`

### using exiftool

The git commit hook can also use exiftool to get metadata.

Install it from <http://owl.phy.queensu.ca/~phil/exiftool/>  
`apt-get install libimage-exiftool-perl`

Configure which metadata fields to ask exiftool for: `git config metadata.exiftool "Model ImageSize FocusRange GPSAltitude GPSCoordinates"`

To get a list of all possible fields, run: `exiftool -list`

### using both extract and exiftool

If you want some metadata that extract knows about, and other metadata
that exiftool knows about, just install them both, and set both
`metadata.extract` and `metadata.exiftool`.

### overwriting existing metadata

By default, if a git-annex already has a metadata field for a file,
its value will not be overwritten with metadata taken from files.
To allow overwriting, run: `git config metadata.overwrite true`