-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (33 loc) · 1.12 KB
/
index.js
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
const fs = require('fs')
const path = require('path')
const exiftool = require('node-exiftool')
const ep = new exiftool.ExiftoolProcess()
// const dirname = path.join(__dirname, 'test')
const dirname = '/Users/mac/Pictures/Garmin'
function writeExif(ep, filepath, metadata) {
console.log(filepath, metadata)
return ep.writeMetadata('destination.jpg', {
all: '', // remove existing tags
comment: 'Exiftool rules!',
'Keywords+': [ 'keywordA', 'keywordB' ],
}, ['overwrite_original'])
// .then(console.log, console.error)
}
const toModify = new Map()
async function main() {
const pid = await ep.open()
console.log('process running on pid', pid)
for (const filename of fs.readdirSync(dirname)) {
const filepath = path.join(dirname, filename)
const metadata = await ep.readMetadata(filepath, ['-File:all'])
const GPSTrack = metadata.data[0].GPSTrack
console.log(metadata.data[0].GPSTrack)
console.log(metadata.data[0].GPSImgDirection)
const status = await ep.writeMetadata(filepath, {
GPSImgDirection: GPSTrack
}, ['overwrite_original'])
console.log(status)
}
ep.close()
}
main()