Page 1 of 1
Split TV Shows between 2 folders
Posted: 29 Oct 2022, 15:27
by valiantslack
Have been using the GUI for years with multiple presets that I have created. Just diving into using AMC so I can automate the process fully.
I have TV Shows separated into two categories Kids and Adults (T:\TV Shows\Adults & T:\TV Shows\Kids). Is there a way to have AMC separate these out automatically? If not I might just have it auto process all the adult shows (more volume) and use the GUI for kid shows.
Script currently is as follows
Code: Select all
filebot -script fn:amc --output "T:/" --action copy --conflict auto --def pushover=APIKey -non-strict "T:/#NewTorrents" --log-file "T:/#NewTorrents/AMC/amc.log" --def excludeList="T:/#NewTorrents/AMC/amcexclude.txt" --action test
Re: Split TV Shows between 2 folders
Posted: 29 Oct 2022, 15:34
by valiantslack
Should also mention I have a similar situation when it comes to movies.
Folder Structure for Plex:
Code: Select all
T:/Movies/Family
T:/Movies/Adults
T:/TV Shows/Kids
T:/TV Shows/Adults
Re: Split TV Shows between 2 folders
Posted: 29 Oct 2022, 16:17
by rednoah
How do you decide the target folder for any given file? If you can express that decision in code, then you just need to pass a custom format into the
amc script call and have it generate different file paths for different files / movies / episodes.
Re: Split TV Shows between 2 folders
Posted: 29 Oct 2022, 20:08
by valiantslack
I've been able to modify the script to at least point to the adults section. Not sure how to tell it to do Adults vs Family movies as I currently just use different presets depending on the Movie/Show.
Code: Select all
filebot -script fn:amc --output "T:/" --action copy --conflict auto --def pushover=Key-non-strict "T:/#NewTorrents" --def movieFormat="T:/Movies/Adults/{plex.derive{"[$vf]"}.name}/{plex.name}" seriesFormat="T:/TV Shows/Adults/{plex.tail}" --log-file "T:/#NewTorrents/AMC/amc.log" --def excludeList="T:/#NewTorrents/AMC/amcexclude.txt" --action test
It appears the script isn't honoring the $vf option as it isn't showing the quality of the movie in the output. It also wouldn't accept $certification.
Here is how my preset for movies is currently set
Code: Select all
T:/Movies/Adults/{n} ({y}) [{vf}] [{certification}]/{n} ({y}) [{vf}] [{group}]
Edit: Logfile -
https://pastebin.com/XF2qHzBB
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 04:17
by rednoah
1.
I see. So you yourself decide which is which. FileBot cannot reproduce your decision making process, but it can make simple decisions based on the available movie / series information, such as
tags,
certifications, etc.

Please provide a TheMovieDB links for various movies / TV shows for
each of your target folders, so that we can compare and contrast and write code to differentiate files / movie / series information.
e.g.
Code: Select all
{ any{ certification ==~ /PG-13/ ? 'Children' : 'Adults' }{ 'UNRATED' } }
2.
You mean to pass in this format:
Code: Select all
T:/Movies/Adults/{plex.derive{"[$vf]"}.name}/{plex.name}
But you effectively pass in this format:
Code: Select all
Parameter: movieFormat = T:/Movies/Adults/{plex.derive{[$vf, $vc]}.name}/{plex.name}
Because the "..." that is part of your format value is interpreted away by the shell. This is a common user error if you're new to the command-line. You can't just copy & paste your format onto the command-line. Please read
Cmdline and Argument Passing for details.

Note that your custom movie format will not work right for subtitle files and multi-part movies.
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 04:43
by rednoah
You can start with something like this:
Code: Select all
T:/Movies
/{ any{ certification =~ /G/ ? 'Children' : 'Adults' }{ 'UNRATED' } }
/{ ~plex * { ' ' + [vf, vc] } }
* take care of
certification being undefined
* use
{plex} operators to append values to the movie / series folder name
* avoid using " in Groovy code so that you can just copy & paste it onto the command-line
(though you shouldn't; use @files instead)
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 06:31
by valiantslack
Thanks for the context and about using escape for quotes.
I'm starting to use the context you provided (thanks btw!) and tweaking it. What would cause a movie content rating to not be pulled (think I might just default it to the Adults folder)?
Will test it out some more and see what it does with different movies and ratings.
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 06:55
by rednoah
Some information may be missing for less popular movies, or brand new movies, because nobody has bothered to enter the missing information yet:
Code: Select all
$ filebot -list --q "alien vs predator" --db TheMovieDB -non-strict --format "{id} | {n} | {certification}"
395 | AVP: Alien vs. Predator | PG-13
960947 | Alien vs Predator |
440 | Aliens vs Predator: Requiem | R
548257 | Alien Predator | NR
67203 | Arctic Predator |
e.g.
PG-13
https://www.themoviedb.org/movie/395
e.g.
R
https://www.themoviedb.org/movie/440
e.g.
undefined
https://www.themoviedb.org/movie/960947
https://www.themoviedb.org/movie/67203
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 15:12
by valiantslack
I've tried to add another content rating for Family movies so that everything G or PG goes to Family and PG-13 + goes to Adults. Trying several methods, it doesn't appear to take for me, it ends up dumping everything into Adults (G and PG).
Code: Select all
filebot -script fn:amc --output "T:/" --action move --conflict auto --def pushover=API -non-strict "T:/#NewTorrents" --def movieFormat="T:/Movies/{ any{ certification =~ /G or PG/ ? 'Family' : 'Adults' }{ 'Adults' } }/{ ~plex * { ' ' + [vf] + [certification] } }" seriesFormat="T:/TV Shows/Adults/{plex.tail}" --log-file "T:/#NewTorrents/AMC/amc.log" --def excludeList="T:/#NewTorrents/AMC/amcexclude.txt" --action test
Also tried (and a few others) with no success.
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 15:40
by valiantslack
Ok, got it working with the following:
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 16:19
by rednoah
=~ is the find-match operator, i.e.
x =~ /G/ returns true for any x that contains G, such as G, PG, PG-13, etc:
==~ is the exact-match operator, i.e.
x ==~ /G|PG/ returns true if x is G or PG:
== is the equals operator:
certification == /G|PG/ notably cannot work because
== works with String literals and not
regex patterns, and since
certification will never have the exact String value
"G|PG" it will always return false.
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 16:23
by valiantslack
Ok, was able to get the same filtering based on content rating for TV shows.
Code: Select all
seriesFormat="T:/TV Shows/{ any{ certification =~ /"TV-Y"|"TV-Y7"/ ? 'Kids' : 'Adults' }{ 'Adults'} }/{plex.derive {n.colon(' ')}.tail}"
Is there a way to keep it form adding a dash and just leaving a space? It appears it turns the colon into a dash?
I tried adding the below with no luck.
Eg.
Code: Select all
Fetching episode data for [CSI: Vegas]
+- 20 episodes
[TEST] from [T:\#NewTorrents\CSI.Vegas.S02E05.In.Harms.Way.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv] to [T:\TV Shows\Adults\CSI - Vegas\Season 02\CSI - Vegas - S02E05 - In Harm's Way.mkv]
Edit: will update to
==~
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 16:32
by rednoah
1.
Compare & Contrast:
Code: Select all
$ echo "any{ certification =~ /"TV-Y"|"TV-Y7"/ ? 'Kids' : 'Adults' }{ 'Adults'} }"
any{ certification =~ /TV-Y|TV-Y7/ ? 'Kids' : 'Adults' }{ 'Adults'} }
You're adding "..." in your
/TV-Y|TV-Y7/ regex pattern for no reason. And the shell interprets them away making your code maybe work. This is very unnecessary and very confusing. Don't do that.
2.
The
{plex} format indeed replaces
: colon characters with
- dash to guarantee Windows-compatible file paths. You cannot change internal behaviour. You can only add bits and pieces.
(NOTE: the bits and pieces you add will be normalised as well with the same internal logic)

Advanced users may read the
{plex} format documentation and find a way to disable file path sanitization entirely. However, this is generally a bad idea for Windows users.
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 16:44
by valiantslack
Got it, think I added the quotes as I was originally having issues. Changed
=~ with
==~ and removed the quotes.
Unfortunate that I can't remove the
- dash, the GUI preset I use does not add a dash in the name, but I suppose it's not a huge deal.
I think I will dry run this in test mode for ~ a week and continue using the GUI until I'm comfortable with the renaming.
Appreciate the help with getting my script to this point
One final question

if I want the script to completely ignore 4k movies (moves to a completely different area) will the following code work?
Re: Split TV Shows between 2 folders
Posted: 30 Oct 2022, 16:55
by rednoah
valiantslack wrote: ↑30 Oct 2022, 16:44
Unfortunate that I can't remove the - dash, the GUI preset I use does not add a dash in the name, but I suppose it's not a huge deal.
The
{plex} format works the same in both GUI and CLI and will replace
: colon. You can always
not use the
{plex} format and write your own format using building blocks such as
{n} {s00e00} {t} etc instead, i.e. you can do whatever you want if you do it yourself.
valiantslack wrote: ↑30 Oct 2022, 16:44
if I want the script to completely ignore 4k movies (moves to a completely different area) will the following code work?
The
--def ignore option allows you exclude files where the file path matches a given regex pattern. If you do
--def ignore="2160p" then that'll ignore files that contain "2160p" in the file path. If your 4K movie have "2160p" in the file path then it'll work, if not, then not.