Page 1 of 1

Trying to combine these two...

Posted: 18 Apr 2013, 18:45
by bonelifer
Current TV renaming scheme:

Code: Select all

Y:/Videos/TV/{def a; new File('Y:/incoming/scripts/names.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; a ?: n.upperInitial().replaceTrailingBrackets()}/{"Season"} {s.pad(2)}/{def a; new File('Y:/incoming/scripts/names.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; a ?: n.upperInitial().replaceTrailingBrackets()} - [{s.pad(2)}x{e.pad(2)}] - {t}
I'd like to add this code to have it put the series on the drive with the most space if the Series doesn't already exist on one of them:

Code: Select all

{["T:", "Y:"].collect{"$it/Videos/TV/$n" as File}.sort{a,b -> a.exists() <=> b.exists() ?: a.root.freeSpace <=> b.root.freeSpace}.last()}/
Tried multiple times to combine them. Still want the renaming capability of the original script for naming the series folder.

Re: Trying to combine these two...

Posted: 19 Apr 2013, 03:17
by rednoah
You just need to create File objects to the series folder on different drives:

This is the key snipped:

Code: Select all

["T:", "Y:"].collect{ drive -> def a; new File('Y:/incoming/scripts/names.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; return new File(drive+"/Videos/TV/", a)
Pretty much like this, minus the typos and syntax errors.

Re: Trying to combine these two...

Posted: 19 Apr 2013, 04:15
by bonelifer
Couldn't figure that out. Plus does that even check to see if the Series folder already exist?

Re: Trying to combine these two...

Posted: 19 Apr 2013, 05:07
by rednoah
Nope, that's just the part you couldn't figure out.

If you paste that into the format I posted you'd get this:

Code: Select all

{["T:", "Y:"].collect{ drive -> def a; new File('Y:/incoming/scripts/names.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; return new File(drive+"/Videos/TV/", a) }.sort{ a,b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{episode}

Re: Trying to combine these two...

Posted: 19 Apr 2013, 16:57
by bonelifer
I get this error:
ambig.gif

Re: Trying to combine these two...

Posted: 19 Apr 2013, 17:23
by rednoah

Code: Select all

{["T:", "Y:"].collect{ drive -> def a=n; new File('D:/names.csv').splitEachLine(';'){if (n==it[0]) a=it[1]}; return new File(drive+"/Videos/TV/", a)}.sort{ a,b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{episode}

Re: Trying to combine these two...

Posted: 19 Apr 2013, 18:11
by bonelifer
Thanks. Works perfectly.