filebot/website/scripts/watcher.groovy

20 lines
625 B
Groovy
Raw Normal View History

// EXPERIMENTAL // HERE THERE BE DRAGONS
// BEGIN SANITY CHECK
if (_prop['java.runtime.version'] < '1.7') throw new Exception('Java 7 required')
if (!(new File(_args.format ?: '').absolute)) throw new Exception('Absolute target path format required')
// END
2011-12-01 17:06:51 +00:00
// watch folders and print files that were added/modified (requires Java 7)
2011-12-20 13:03:28 +00:00
def watchman = args.watch { changes ->
2011-12-20 02:39:33 +00:00
println "Processing $changes"
rename(file:changes)
2011-12-20 02:39:33 +00:00
}
// process after 10 minutes without any changes to the folder
watchman.setCommitDelay(10 * 60 * 1000)
2011-12-01 17:06:51 +00:00
println "Waiting for events"
2011-12-20 02:39:33 +00:00
console.readLine() // keep running and watch for changes