1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 09:18:51 -05:00
filebot/website/scripts/watcher.groovy

19 lines
666 B
Groovy
Raw Normal View History

2012-01-05 00:30:22 -05:00
// filebot -script "http://filebot.sf.net/scripts/watcher.groovy" --format <expression> <folder>
2012-01-05 00:30:22 -05:00
// 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')
2011-12-01 12:06:51 -05:00
// watch folders and print files that were added/modified (requires Java 7)
2011-12-20 08:03:28 -05:00
def watchman = args.watch { changes ->
2011-12-19 21:39:33 -05:00
println "Processing $changes"
rename(file:changes)
2011-12-19 21:39:33 -05:00
}
2012-01-05 00:30:22 -05:00
// process after 5 minutes without any changes to the folder
watchman.setCommitDelay(5 * 60 * 1000)
2011-12-01 12:06:51 -05:00
println "Waiting for events"
2011-12-19 21:39:33 -05:00
console.readLine() // keep running and watch for changes