Created
July 26, 2013 18:08
-
-
Save leonard84/6090943 to your computer and use it in GitHub Desktop.
Move unmatched files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: amc.groovy | |
=================================================================== | |
--- amc.groovy (revision 1674) | |
+++ amc.groovy (working copy) | |
@@ -24,6 +24,7 @@ | |
def backdrops = tryQuietly{ backdrops.toBoolean() } | |
def clean = tryQuietly{ clean.toBoolean() } | |
def exec = tryQuietly{ exec.toString() } | |
+def unmatched = tryQuietly{ unmatched.toString() } | |
// array of xbmc/plex hosts | |
def xbmc = tryQuietly{ xbmc.split(/[ ,|]+/) } | |
@@ -312,6 +313,19 @@ | |
) | |
} | |
+// if defined move all unmatched to $unmatched | |
+if (unmatched) { | |
+ def target = new File(unmatched) | |
+ target.mkdirs() | |
+ | |
+ tempFiles.findAll{it.isFile() && !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook|behind.the.scenes)\b/ || (it.length() < minFileSize)) }.each { | |
+ | |
+ def newFile = new File(target, it) | |
+ _log.info "Move unmatched $it.name to $newFile.path" | |
+ it.renameTo(newFile) | |
+ } | |
+} | |
+ | |
// clean empty folders, clutter files, etc after move | |
if (clean) { | |
if (['COPY', 'HARDLINK'].find{ it.equalsIgnoreCase(_args.action) } && tempFiles.size() > 0) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment