mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -05:00
* normalize path separators for windows so scripts using execute with native path strings will work all platforms
This commit is contained in:
parent
dced0140d6
commit
9af051f08e
@ -4,6 +4,7 @@ package net.sourceforge.filebot.cli;
|
||||
|
||||
import static net.sourceforge.filebot.cli.CLILogging.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilePermission;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.SocketPermission;
|
||||
@ -52,6 +53,7 @@ class ScriptShell {
|
||||
|
||||
protected Bindings initializeBindings(CmdlineInterface cli, ArgumentBean args, AccessControlContext acc) {
|
||||
Bindings bindings = new SimpleBindings();
|
||||
bindings.put("_script", new File(args.script));
|
||||
bindings.put("_cli", PrivilegedInvocation.newProxy(CmdlineInterface.class, cli, acc));
|
||||
bindings.put("_args", args);
|
||||
bindings.put("_types", MediaTypes.getDefault());
|
||||
|
@ -2,7 +2,7 @@
|
||||
import static groovy.io.FileType.*
|
||||
|
||||
|
||||
File.metaClass.plus = { path -> new File(delegate, path) }
|
||||
File.metaClass.node = { path -> new File(delegate, path) }
|
||||
File.metaClass.listFiles = { c -> delegate.isDirectory() ? delegate.listFiles().findAll(c) : []}
|
||||
|
||||
File.metaClass.isVideo = { _types.getFilter("video").accept(delegate) }
|
||||
@ -29,6 +29,7 @@ List.metaClass.eachMediaFolder = { c -> getFolders().findAll{ it.hasFile{ it.isV
|
||||
import static net.sourceforge.tuned.FileUtilities.*;
|
||||
|
||||
File.metaClass.getNameWithoutExtension = { getNameWithoutExtension(delegate.getName()) }
|
||||
File.metaClass.getPathWithoutExtension = { new File(delegate.getParentFile(), getNameWithoutExtension(delegate.getName())).getPath() }
|
||||
File.metaClass.getExtension = { getExtension(delegate) }
|
||||
File.metaClass.hasExtension = { String... ext -> hasExtension(delegate, ext) }
|
||||
File.metaClass.isDerived = { f -> isDerived(delegate, f) }
|
||||
@ -46,10 +47,11 @@ def execute(String... args) {
|
||||
_log.severe("Execute failed: Script is not trusted");
|
||||
return -1
|
||||
}
|
||||
|
||||
|
||||
def cmd = args.toList()
|
||||
if (isWindows()) {
|
||||
cmd = ["cmd", "/c"] + cmd;
|
||||
// normalize file separator for windows and run with cmd so any executable in PATH will just work
|
||||
cmd = ['cmd', '/c'] + cmd*.replace('/','\\')
|
||||
}
|
||||
|
||||
// run command and print output
|
||||
|
@ -7,12 +7,9 @@ def movieFormat = "X:/out/Movies/{movie}/{movie}"
|
||||
|
||||
def exclude(f) { f =~ /\p{Punct}(chunk|part)/ }
|
||||
|
||||
// run cmdline unrar / unzip (require -trust-script)
|
||||
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('zip') }.each {
|
||||
execute("unzip", it.getAbsolutePath());
|
||||
}
|
||||
// run cmdline unrar (require -trust-script)
|
||||
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each {
|
||||
execute("unrar", "-x", it.getAbsolutePath());
|
||||
execute("unrar", "x", "-y", it.getAbsolutePath(), it.getPathWithoutExtension() + "/")
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user