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) } }