2012-10-14 04:30:52 +00:00
|
|
|
// filebot -script fn:replace --action copy --filter "[.]srt$" --def "e=[.](eng|english)" "r=.en"
|
2012-10-13 04:48:08 +00:00
|
|
|
|
|
|
|
// imports
|
|
|
|
import net.sourceforge.filebot.StandardRenameAction
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
def action = StandardRenameAction.forName(_args.action)
|
|
|
|
def accept = { f -> _args.filter ? f.path =~ _args.filter : true }
|
|
|
|
|
|
|
|
// rename
|
|
|
|
args.getFiles{ accept(it) }.each{
|
|
|
|
if (it.path =~ e) {
|
|
|
|
def nfile = new File(it.path.replaceAll(e, r))
|
|
|
|
|
|
|
|
// override files only when --conflict override is set
|
|
|
|
if (!it.equals(nfile)) {
|
2013-01-09 09:08:53 +00:00
|
|
|
if (nfile.exists() && _args.conflict == 'override' && action != StandardRenameAction.TEST) {
|
2013-01-10 19:30:16 +00:00
|
|
|
nfile.delete() // resolve conflict
|
2012-10-13 04:48:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-09 09:08:53 +00:00
|
|
|
if (!nfile.exists()) {
|
|
|
|
println action.rename(it, nfile)
|
|
|
|
} else {
|
|
|
|
println "Skipped $nfile"
|
|
|
|
}
|
2012-10-13 04:48:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|