From 3bcfab4dc9be18c6f80c22e7fcfa81103988a386 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 7 May 2013 15:01:50 +0000 Subject: [PATCH] * keep clean-root folders by default, i.e. exclude from delete --- website/scripts/amc.groovy | 2 +- website/scripts/cleaner.groovy | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/website/scripts/amc.groovy b/website/scripts/amc.groovy index 2bd9821b..1aa99343 100644 --- a/website/scripts/amc.groovy +++ b/website/scripts/amc.groovy @@ -321,6 +321,6 @@ if (clean) { // deleting remaining files only makes sense after moving files if ('MOVE'.equalsIgnoreCase(_args.action)) { _log.info 'Clean clutter files and empty folders' - include('fn:cleaner', [:], !args.empty ? args : ut_kind == 'multi' && ut_dir ? [ut_dir as File] : []) + include('fn:cleaner', [root:true], !args.empty ? args : ut_kind == 'multi' && ut_dir ? [ut_dir as File] : []) } } diff --git a/website/scripts/cleaner.groovy b/website/scripts/cleaner.groovy index bff92405..7056d218 100644 --- a/website/scripts/cleaner.groovy +++ b/website/scripts/cleaner.groovy @@ -1,4 +1,5 @@ // filebot -script fn:cleaner [--action test] /path/to/media/ +def deleteRootFolder = tryQuietly{ root.toBoolean() } /* * Delete orphaned "clutter" files like nfo, jpg, etc and sample files @@ -29,4 +30,4 @@ def clean(f) { args.getFiles{ isClutter(it) && !it.dir.hasFile{ (it.isVideo() || it.isAudio()) && !isClutter(it) }}.each { clean(it) } // delete empty folders but exclude given args -args.getFolders().sort().reverse().each { if (it.listFiles().length == 0) { clean(it) } } +args.getFolders().sort().reverse().each { if (it.listFiles().length == 0) { if (deleteRootFolder || !args.contains(it)) clean(it) } }