From c5f3a89ed09eb346acc83394601087fbd349fe98 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 17 Nov 2012 04:14:09 +0000 Subject: [PATCH] + added a cmdline script for reverting previously renamed files --- .../filebot/StandardRenameAction.java | 14 ++++++++++++++ website/data/query-blacklist.txt | 3 ++- website/scripts/revert.groovy | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 website/scripts/revert.groovy diff --git a/source/net/sourceforge/filebot/StandardRenameAction.java b/source/net/sourceforge/filebot/StandardRenameAction.java index 3b2524e2..b5e8772a 100644 --- a/source/net/sourceforge/filebot/StandardRenameAction.java +++ b/source/net/sourceforge/filebot/StandardRenameAction.java @@ -78,6 +78,20 @@ public enum StandardRenameAction implements RenameAction { } }, + RENAME { + + @Override + public File rename(File from, File to) throws IOException { + // rename only the filename + File dest = new File(from.getParentFile(), to.getName()); + + if (!from.renameTo(dest)) + throw new IOException("Rename failed: " + dest); + + return dest; + } + }, + TEST { @Override diff --git a/website/data/query-blacklist.txt b/website/data/query-blacklist.txt index 6738d7e7..fde10218 100644 --- a/website/data/query-blacklist.txt +++ b/website/data/query-blacklist.txt @@ -29,6 +29,7 @@ ^Downloads$ ^DVD ^Erotic$ +^Extract$ ^Film[s]? ^Finished ^Horror$ @@ -72,8 +73,8 @@ Demonoid Director's.Cut Directors.Cut Discovery.Channel -DLLValley.eu DLLValley +DLLValley.eu docu Dual.Audio dubbed diff --git a/website/scripts/revert.groovy b/website/scripts/revert.groovy new file mode 100644 index 00000000..a489175b --- /dev/null +++ b/website/scripts/revert.groovy @@ -0,0 +1,19 @@ +// filebot -script fn:revert + + +def accept(from, to) { + args.find{ to.absolutePath.startsWith(it.absolutePath) } && to.exists() +} + +def revert(from, to) { + def action = net.sourceforge.filebot.StandardRenameAction.forName(_args.action) + + println "[$action] Revert [$from] to [$to]" + action.rename(from, to) +} + + +getRenameLog(true).reverseEach { from, to -> + if (accept(from, to)) + revert(to, from) +}