Skip to content

Instantly share code, notes, and snippets.

@leonard84
Created July 26, 2013 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonard84/6090943 to your computer and use it in GitHub Desktop.
Save leonard84/6090943 to your computer and use it in GitHub Desktop.
Move unmatched files
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