* added new example script

This commit is contained in:
Reinhard Pointner 2011-11-03 05:50:57 +00:00
parent 38d9903d0f
commit ba119efdde
2 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,7 @@ File.metaClass.isSubtitle = { _types.getFilter("subtitle").accept(delegate) }
File.metaClass.isVerification = { _types.getFilter("verification").accept(delegate) }
File.metaClass.hasFile = { c -> isDirectory() && listFiles().find{ c.call(it) }}
File.metaClass.plus = { path -> new File(delegate, path) }
File.metaClass.getFiles = { def files = []; traverse(type:FILES) { files += it }; return files }
List.metaClass.getFiles = { findResults{ it.getFiles() }.flatten().unique() }
@ -15,9 +16,12 @@ List.metaClass.getFiles = { findResults{ it.getFiles() }.flatten().unique() }
File.metaClass.getFolders = { def folders = []; traverse(type:DIRECTORIES, visitRoot:true) { folders += it }; return folders }
List.metaClass.getFolders = { findResults{ it.getFolders() }.flatten().unique() }
File.metaClass.eachMediaFolder = { c -> getFolders().findAll{ it.hasFile{ it.isVideo() } }.each(c) }
List.metaClass.eachMediaFolder = { c -> getFolders().findAll{ it.hasFile{ it.isVideo() } }.each(c) }
def require(cond) {
if (!cond()) throw new Exception('Require failed')
}
def rename(args) { args = _defaults(args)

View File

@ -0,0 +1,19 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/mvrn.groovy" --format "{n}/{n} - {'S'+s.pad(2)}E{e.pad(2)} - {t}" --db thetvdb <source folder> <destination folder>
// sanity check
require { args.size == 2 && _args.format && _args.db }
// handle arguments
def source = args[0]
def destination = args[1] + _args.format
println 'Source Folder: ' + source
println 'Target Format: ' + destination.path
/*
* Move/Rename videos from source folder into destination folder
*/
source.eachMediaFolder {
println 'Processing ' + it
rename(folder:it, format:destination.path, db:_args.db)
}