Help with "Sort into drive with the most free space:"

Any questions? Need some help?
Post Reply
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Help with "Sort into drive with the most free space:"

Post by csantiago78 »

Hi Guys,

I Am running filebot on a MAC, and I need your help understanding a bit better how the "Sort into drive with the most free space" script works with the amc.groovy.

I have already read a couple of threads with suggestions

And I need anything on the "/Users/csantiago78/Downloads/jd/" folder to be processed and moved accordingly to one of these places(if necessary I could unify the folder names to "TV Shows" in all of the locations):
/Users/csantiago78/Movies/All Media/TV Shows
/Volumes/LG External/- TV Shows
/Volumes/TSHBA_EXT01/Downloads/TV_Shows
/Volumes/Bootcamp/Users/csantiago78/Downloads/TV Shows

but basically this is what I am using from terminal with not so good results:

Code: Select all

/Applications/FileBot.app/Contents/MacOS/filebot -script fn:amc "/Users/csantiago78/Downloads/jd/" --log-file "/Users/csantiago78/Downloads/amc.log" --action move --conflict override -non-strict --def music=n "subtitles=es,en" artwork=y "seriesFormat={[\"/Users/csantiago78/Movies/All Media/TV Shows\", \"/Volumes/LG External/- TV Shows\", \"/Volumes/TSHBA_EXT01/Downloads/TV_Shows\", \"/Volumes/Bootcamp/Users/csantiago78/Downloads/TV Shows\"].collect{\"$it/$n\" as File}.sort{a,b -> a.exists() <=> b.exists() ?: a.root.freeSpace <=> b.root.freeSpace}.last()}/{n}{y}/Season {s}/{n.space('.')}.{'s'+s.pad(2)}e{e.pad(2)}.{vf}.{vc}.{ac}-{group}"
This is the output:

Code: Select all

sh-3.2# /Applications/FileBot.app/Contents/MacOS/filebot -script fn:amc "/Users/csantiago78/Downloads/jd/" --log-file "/Users/csantiago78/Downloads/amc.log" --action move --conflict override -non-strict --def music=n "subtitles=es,en" artwork=y "seriesFormat={[\"/Users/csantiago78/Movies/All Media/TV Shows\", \"/Volumes/LG External/- TV Shows\", \"/Volumes/TSHBA_EXT01/Downloads/TV_Shows\", \"/Volumes/Bootcamp/Users/csantiago78/Downloads/TV Shows\"].collect{\"$it/$n\" as File}.sort{a,b -> a.exists() <=> b.exists() ?: a.root.freeSpace <=> b.root.freeSpace}.last()}/{n}{y}/Season {s}/{n.space('.')}.{'s'+s.pad(2)}e{e.pad(2)}.{vf}.{vc}.{ac}-{group}"
Locking /Users/csantiago78/Downloads/amc.log
Parameter: music = n
Parameter: subtitles = es,en
Parameter: artwork = y
Parameter: seriesFormat = {["/Users/csantiago78/Movies/All Media/TV Shows", "/Volumes/LG External/- TV Shows", "/Volumes/TSHBA_EXT01/Downloads/TV_Shows", "/Volumes/Bootcamp/Users/csantiago78/Downloads/TV Shows"].collect{"/" as File}.sort{a,b -> a.exists() <=> b.exists() ?: a.root.freeSpace <=> b.root.freeSpace}.last()}/{n}{y}/Season {s}/{n.space('.')}.{'s'+s.pad(2)}e{e.pad(2)}.{vf}.{vc}.{ac}-{group}
Argument: /Users/csantiago78/Downloads/jd
Input: /Users/csantiago78/Downloads/jd/Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.eng.srt
Input: /Users/csantiago78/Downloads/jd/Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.mkv
Group: [tvs:Castle 2009] => [Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.eng.srt, Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.mkv]
Get [Spanish] subtitles for 1 files
Looking up subtitles by filehash via OpenSubtitles
Searching for [Castle 2009] at [OpenSubtitles]
Matched [Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.mkv] to [Castle.2009.S06E05.HDTV.XviD-FUM] via filename
Fetching [Castle.2009.S06E05.HDTV.XviD-FUM.srt]
Export [Castle.2009.S06E05.HDTV.XviD-FUM.srt] as: SubRip / UTF-8
Writing [Castle.2009.S06E05.HDTV.XviD-FUM.srt] to [Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.spa.srt]
No missing subtitles
Rename episodes using [TheTVDB]
Auto-detected query: [Castle 2009]
Fetching episode data for [Castle (2009)]
Auto-detected query: [Castle 2009]
Fetching episode data for [Castle (2009)]
Auto-detected query: [Castle 2009]
Fetching episode data for [Castle (2009)]
Failed to write xattr: java.io.File.toPath()Ljava/nio/file/Path;
[MOVE] Rename [/Users/csantiago78/Downloads/jd/Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.spa.srt] to [/Castle (2009)2009/Season 6/Castle.(2009).s06e05.720p.x264.AC3-DIMENSION.srt]
[MOVE] Rename [/Users/csantiago78/Downloads/jd/Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.eng.srt] to [/Castle (2009)2009/Season 6/Castle.(2009).s06e05.720p.x264.AC3-DIMENSION.srt]
[MOVE] Rename [/Users/csantiago78/Downloads/jd/Castle.2009.S06E05.720p.HDTV.X264-DIMENSION.mkv] to [/Castle (2009)2009/Season 6/Castle.(2009).s06e05.720p.x264.AC3-DIMENSION.mkv]
Processed 3 files
Fetching artwork for /Castle (2009)2009/Season 6 from TheTVDB
Fetching /Castle (2009)2009/poster.jpg => {id=924185, BannerMirror=http://thetvdb.com/banners/, BannerPath=posters/83462-8.jpg, BannerType=poster, BannerType2=680x1000, Language=en, Rating=6.7778, RatingCount=9}
Fetching /Castle (2009)2009/banner.jpg => {id=454221, BannerMirror=http://thetvdb.com/banners/, BannerPath=graphical/83462-g9.jpg, BannerType=series, BannerType2=graphical, Language=en, Rating=7.2500, RatingCount=4}
Fetching /Castle (2009)2009/fanart.jpg => {id=924257, BannerMirror=http://thetvdb.com/banners/, BannerPath=fanart/original/83462-33.jpg, BannerType=fanart, BannerType2=1920x1080, Language=en, Rating=7.7500, RatingCount=8, SeriesName=false, ThumbnailPath=_cache/fanart/original/83462-33.jpg, VignettePath=fanart/vignette/83462-33.jpg}
Fetching /Castle (2009)2009/Season 6/poster.jpg => {id=979831, BannerMirror=http://thetvdb.com/banners/, BannerPath=seasons/83462-6-6.jpg, BannerType=season, BannerType2=season, Season=6, Language=en, Rating=7.0000, RatingCount=3}
Banner not found: /Castle (2009)2009/Season 6/banner.jpg / season:seasonwide
Fetching /Castle (2009)2009/clearart.png => {type=clearart, id=5659, url=http://assets.fanart.tv/fanart/tv/83462/clearart/C_83462 (3).png, lang=en, likes=5}
Fetching /Castle (2009)2009/logo.png => {type=clearlogo, id=183, url=http://assets.fanart.tv/fanart/tv/83462/clearlogo/castle(2009)-83462.png, lang=en, likes=3}
Fetching /Castle (2009)2009/landscape.jpg => {type=tvthumb, id=5667, url=http://assets.fanart.tv/fanart/tv/83462/tvthumb/C_83462 (8).jpg, lang=en, likes=1}
Fanart not found: /Castle (2009)2009/Season 6/landscape.jpg / seasonthumb
Done ヾ(@⌒ー⌒@)ノ
I am only leaving 2 files over there for testing purposes, but instead of moving the files to the locations I want to, it's moving them to the "/" of the MAC drive with the folder structure, also it is leaving the folder as: "/Castle (2009)2009" when what I want it to be is "Castle(2009)".

Sorry I am not very good at scripting. :oops:

Thanks!!
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

Support Donation before I even answer? Very much appreciated. :)


You can easily prototype the format in the GUI. This looks wrong:

Code: Select all

[s1, s2 , s3].collect{"/" as File}
The point is to convert the String objects into File objects, but you're just casting "/" to File.

I think my examples do this, the it is key:

Code: Select all

[s1, s2 , s3].collect{"$it/TV/$n" as File}
In your case you can just do:

Code: Select all

[s1, s2 , s3].collect{it as File}
But the logic doesn't make sense now, it'll sort those by most-space as well as already-exists. Since your root tv folders always exist it'll always pick the first one.

You will at least need to add the series name to your root TV folder name:

Code: Select all

[s1, s2 , s3].collect{"$it/$n" as File}}
This one should work. :ugeek:
:idea: Please read the FAQ and How to Request Help.
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Re: Help with "Sort into drive with the most free space:"

Post by csantiago78 »

WOW!! Thanks for the prompt help!!! I forgot to subscribe to the email updates on the forum and didn't realized you had already answered.

The software kicks ass so I think EVERYONE should donate, with no link to getting help or not.

I will test this out and let you know the results!!!

Thanks again!!!
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Re: Help with "Sort into drive with the most free space:"

Post by csantiago78 »

It seems I am having some sort of issue with the double quotes. As though I escaped them, they are not being well interpreted if you check my original command it was just as you suggested. Perhaps they were auto corrected by the Mac dictionary. I Will try again later and let you know.

Thanks for the support man!
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

I wrote this scriptlet to help you escape the format expression for cmdline:

Code: Select all

filebot -script fn:escape
It's just 2-line hack and plenty of room for improvement, but it sure beats manually escaping quotes...
:idea: Please read the FAQ and How to Request Help.
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Re: Help with "Sort into drive with the most free space:"

Post by csantiago78 »

Thanks for the script man! How can I use the amc one and the escape one? Do I need to pipe it or something? or just use the -script twice?

Code: Select all

-script fn:escape -script fn:amc "/Users/csantiago78/Downloads/jd/" .............
Thanks for the great support!!!
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

Just run it:

Code: Select all

filebot -script fn:escape
Then it'll ask you to paste the format, and then it'll output the escaped format, so you can copy that.


You understand that if you can't escape the arguments, how can you pass the correct argument to the escape script? If you could pass the arguments correctly you wouldn't need the script.

The AMC script very thoroughly and with colourful samples shows you how the cmdline parses arguments. Also a billion pages on google and any basic cmdline tutorial.
:idea: Please read the FAQ and How to Request Help.
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Re: Help with "Sort into drive with the most free space:"

Post by csantiago78 »

I figured out... I was properly escaping the double quotes but I didn't know that the $ also needs to be escaped.

Which are the other restricted characters besides from "(double quotes) and the $(dollar sign)?

Thanks for the support!!
csantiago78
Donor
Posts: 10
Joined: 22 Oct 2013, 19:57

Re: Help with "Sort into drive with the most free space:"

Post by csantiago78 »

Another question I have is: how many source drives does it evaluates? I tried with four and it wasn't guessing it right.

Thanks again!
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

It works for an infinite numbers of drives/paths. If your modifications change the logic just use my pristine code.

I assume "source drive" = output folders?

It's simple logic:
1. have a list of all output folders
2. Primary sort by exists (existing folders will come first)
3. Secondary sort by freeSpace (folders with most space come first)

This is the logic of my code. When you change the format make sure you don't inadvertently mess with that.
:idea: Please read the FAQ and How to Request Help.
udelledo
Posts: 7
Joined: 28 Oct 2013, 20:44

Re: Help with "Sort into drive with the most free space:"

Post by udelledo »

Hi,
I'm trying to tweak the series format to fit my folder structure, but I'm not being very successful at getting it to work.

Considering that the user in this post is using a mac as I need, I thought it was a simple matter of updating the paths in the script but it doesn't look that way. Since just updating the folders didn't work I tried to get the proper format using the GUI editor.

I found a format that worked with the GUI and I used the escape script to have a properly escaped string

Code: Select all

*****:MacOS *****$ ./filebot  -script fn:escape
Enter: {["/Volumes/Public", "/Volumes/Public-1"].collect{"$it/Shared Videos/Serie TV/$n" as File}.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{"Season "+s}/{n} - {s00e00} - {t}

"{[\"/Volumes/Public\", \"/Volumes/Public-1\"].collect{\"\$it/Shared Videos/Serie TV/\$n\" as File}.sort{ a, b -\> a.exists() \<=\> b.exists() ?: a.diskSpace \<=\> b.diskSpace }.last()}/{\"Season \"+s}/{n} - {s00e00} - {t}"
I'm running FileBot with the following command:

Code: Select all

./filebot -script fn:amc "/Volumes/Public-1/WWW/TR-Downloads/" --output "/Volumes/Public-1/Shared Videos/" -non-strict --def "gmail=*****:*****" "mailto=********" "xbmc=192.168.1.250" "clean=y" "seriesFormat={[\"/Volumes/Public\", \"/Volumes/Public-1\"].collect{\"\$it/Shared Videos/Serie TV/\$n\" as File}.sort{ a, b -\> a.exists() \<=\> b.exists() ?: a.diskSpace \<=\> b.diskSpace }.last()}/{\"Season \"+s}/{n} - {s00e00} - {t}" "animeFormat=Cartoni/{n}/{fn}" "movieFormat=Film/Lingua Originale/{\"\$collection/\"}{n} ({y})/{fn}" --log-file run.log
but I get the following output:

Code: Select all

Locking /Users/*****/.filebot/logs/run.log
Parameter: gmail = *****
Parameter: mailto = *****
Parameter: xbmc = 192.168.1.250
Parameter: clean = y
Parameter: seriesFormat = {["/Volumes/Public", "/Volumes/Public-1"].collect{"$it/Shared Videos/Serie TV/$n" as File}.sort{ a, b -\> a.exists() \<
Parameter: animeFormat = Cartoni/{n}/{fn}
Parameter: movieFormat = Film/Lingua Originale/{"$collection/"}{n} ({y})/{fn}
Argument: /Volumes/Public-1/WWW/TR-Downloads
Input: /Volumes/Public-1/WWW/TR-Downloads/Da Vinci's Demons - S02E08 - The Fall from Heaven.mkv
Input: /Volumes/Public-1/WWW/TR-Downloads/Da Vinci's Demons - S02E08 - The Fall from Heaven.srt
Group: [tvs:da vincis demons] => [Da Vinci's Demons - S02E08 - The Fall from Heaven.mkv, Da Vinci's Demons - S02E08 - The Fall from Heaven.srt]
javax.script.ScriptException: SyntaxError: missing token: }
Clean clutter files and empty folders
Finished without processing any files
Failure (°_°)
Has anyone faced a similar issue?

Thanks in advance
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

As far as FileBot is concerned, this is what you're passing in:

Code: Select all

{["/Volumes/Public", "/Volumes/Public-1"].collect{"$it/Shared Videos/Serie TV/$n" as File}.sort{ a, b -\> a.exists() \<
This is most obviously not what you want to pass in.

You need to work on escaping things properly. ;)

PS: Have you tried my Escape Tool? Just updated it to NOT escape <>

@see http://www.filebot.net/forums/viewtopic ... 1041#p6427
:idea: Please read the FAQ and How to Request Help.
udelledo
Posts: 7
Joined: 28 Oct 2013, 20:44

Re: Help with "Sort into drive with the most free space:"

Post by udelledo »

I thought it was just a crop in the log of a too long parameters.

I used the escape script as you suggested also to the other user in this thread and the output was the value I used in the CLI interface.

I tried to remove the escape character on both < and > but the result didn't change as the series format is still read from FileBot as

Code: Select all

Locking /Users/udelledo/.filebot/logs/run.log
Parameter: gmail = *****
Parameter: mailto = *****
Parameter: xbmc = 192.168.1.250
Parameter: clean = y
Parameter: seriesFormat = {["/Volumes/Public", "/Volumes/Public-1"].collect{"$it/Shared Videos/Serie TV/$n" as File}.sort{ a, b -> a.exists() <
Parameter: animeFormat = Cartoni/{n}/{fn}
Parameter: movieFormat = Film/Lingua Originale/{collection+"/"}{n} ({y})/{fn}
I also ran the escape tool again, but I still get the same output as before.

Code: Select all

macbook-di-ugo:MacOS udelledo$ date; ./filebot -script fn:escape
Lun 12 Mag 2014 19:26:45 CEST
Enter: {["/Volumes/Public", "/Volumes/Public-1"].collect{"$it/Shared Videos/Serie TV/$n" as File}.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{"Season "+s}/{n} - {s00e00} - {t}

"{[\"/Volumes/Public\", \"/Volumes/Public-1\"].collect{\"\$it/Shared Videos/Serie TV/\$n\" as File}.sort{ a, b -\> a.exists() \<=\> b.exists() ?: a.diskSpace \<=\> b.diskSpace }.last()}/{\"Season \"+s}/{n} - {s00e00} - {t}"
I'm not sure how to solve it, I also tried escaping the = and the ? char, but everything looked the same.
User avatar
rednoah
The Source
Posts: 23933
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with "Sort into drive with the most free space:"

Post by rednoah »

Well, it's so messed up already you can't just fix it. You'll need to build the format step-by-step so you can see at which step the escaping goes wrong.

I'd be smart and just call it differently.

Using xargs is just one idea:
Image
:idea: Please read the FAQ and How to Request Help.
Post Reply