forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatcher.groovy
More file actions
22 lines (17 loc) · 736 Bytes
/
watcher.groovy
File metadata and controls
22 lines (17 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// filebot -script fn:watcher /path/to/folder/ --output /output/folder/ --format <expression>
// watch folders and print files that were added/modified
def watchman = args[0].watch { changes ->
// extract all
if (_args.extract)
changes += extract(file:changes.findAll{ it.isArchive() }, output:'.')
// subtitles for all
if (_args.getSubtitles)
changes += getMissingSubtitles(file:changes.findAll{ it.isVideo() }, output:'srt')
// rename all
if (_args.rename)
rename(file:changes)
}
watchman.commitDelay = 5 * 1000 // default = 5s
watchman.commitPerFolder = true // default = true
println "Waiting for events"
if (console) { console.readLine() } else { sleep(Long.MAX_VALUE) } // keep running and watch for changes