-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
26 lines (20 loc) · 725 Bytes
/
cli.py
File metadata and controls
26 lines (20 loc) · 725 Bytes
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
#!/usr/bin/env python
import argparse
import yaml
import exiftool
with open('lenses.yaml', 'rb') as fh:
config = yaml.load(fh, Loader=yaml.Loader)
parser = argparse.ArgumentParser()
parser.add_argument('--lens', help='Select lens', choices=[l['key'] for l in lenses], required=True)
parser.add_argument('files', nargs='+', help='Files to operate on')
args = parser.parse_args()
exif = {}
for lens in config['lenses']:
if lens['key'] == args.lens:
exif = lens['exif']
break
command = [f'-{key}={value}'.encode('ascii') for key, value in exif.items()]
with exiftool.ExifTool(config['exiftool']) as et:
command += list(map(exiftool.fsencode, args.files))
r = et.execute(*command)
print(r.decode('ascii').strip())