[CODE] FolderWatchService

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
User avatar
rednoah
The Source
Posts: 16303
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[CODE] FolderWatchService

Post by rednoah » 21 Jul 2012, 10:37

Here's a basic example for watching folders for new files. It'll just print the added/changed files.

Code: Select all

// watch folders and print files that were added/modified (requires Java 7)
def watchman = args.watch { files ->
	println files
}

// process after 500ms without any changes to the folder
watchman.commitDelay = 500        // default = 5min
watchman.commitPerFolder = true   // default = true

println 'Waiting for changes'
console.readLine() // keep running and watch for changes
:idea: Please read the FAQ and How to Request Help.

Post Reply