def root = 'D:/workspace/testdata/AMC-TEST'
def configs = [
[inputDir: "$root/TV Shows", outputFormat: '''D:/TV Shows/{n}/Season {s}/{fn}''', db:'TheTVDB'],
[inputDir: "$root/Movies", outputFormat: '''D:/Movies/{n}/{fn}''', db:'TheMovieDB'],
[inputDir: "$root/Anime", outputFormat: '''D:/Anime/{primaryTitle}/{fn}''', db:'AniDB']
]
configs.each{ config ->
def watchman = new File(config.inputDir).watch { changes ->
// extract all
changes += extract(file:changes.findAll{ it.isArchive() }, output:'.')
// rename all
def renamedFiles = rename(file:changes, db:config.db, format:config.format)
def message = renamedFiles.name.join('\n')
execute("sendemail.exe", "-f", "[email protected]", "-t", "[email protected]", "-s", "smtp.server.com:port", "-u", "Changes", "-m", message)
}
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
Comments