1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 09:18:51 -05:00

* cmdline option -r: resolve folders recursively

* get canonical representation of input paths before processing
This commit is contained in:
Reinhard Pointner 2012-07-05 04:08:34 +00:00
parent e535b692ff
commit f844b96f05

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
@ -83,6 +84,9 @@ public class ArgumentBean {
@Option(name = "--log", usage = "Log level", metaVar = "[all, config, info, warning]") @Option(name = "--log", usage = "Log level", metaVar = "[all, config, info, warning]")
public String log = "all"; public String log = "all";
@Option(name = "-r", usage = "Resolve folders recursively")
public boolean recursive = false;
@Option(name = "-open", usage = "Open file in GUI", metaVar = "file") @Option(name = "-open", usage = "Open file in GUI", metaVar = "file")
public boolean open = false; public boolean open = false;
@ -135,9 +139,17 @@ public class ArgumentBean {
// resolve given paths // resolve given paths
for (String argument : arguments) { for (String argument : arguments) {
// resolve folders
File file = new File(argument).getAbsoluteFile(); File file = new File(argument).getAbsoluteFile();
files.addAll(resolveFolders && file.isDirectory() ? listFiles(singleton(file), 0, false) : singleton(file));
// resolve relative paths
try {
file = file.getCanonicalFile();
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage());
}
// resolve folders
files.addAll(resolveFolders && file.isDirectory() ? listFiles(singleton(file), recursive ? 10 : 0, false) : singleton(file));
} }
return files; return files;