mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-17 14:55:09 -05:00
* Regular-expression based mass-rename utility, FileBot style!
This commit is contained in:
parent
6bd0be7845
commit
395de24346
24
website/scripts/replace.groovy
Normal file
24
website/scripts/replace.groovy
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// filebot -script fn:replace --action copy --filter [.]srt$ --def e=[.](eng|english) r=.en
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
if ((nfile.exists() || _args.conflict == 'override') && action != StandardRenameAction.TEST) {
|
||||||
|
nfile.delete(); // resolve conflict
|
||||||
|
}
|
||||||
|
|
||||||
|
println action.rename(it, nfile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user