Exclude name in txt file.

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Exclude name in txt file.

Post by TehJonny »

Hey,

Just wondering how I exclude more then one show from my results for e.g

Code: Select all

--filter "n != /Doctor Who/"
How can I add multiple shows to this code?

Also is it possible to have the filter code above call a text file containing every show to exclude? if so how?

Kind Regards
-Jonathan
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

Yes, you can read files in your --filter Groovy expression. Other threads will show you how to read files, mostly for custom formats but it's the same for filters.
:idea: Please read the FAQ and How to Request Help.
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Re: Exclude name in txt file.

Post by TehJonny »

I cant even figure this out any chance you could give me a hand?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

This page will help. Check out #4:
viewtopic.php?f=5&t=182

You will probably find multiple solutions by searching for "filter" and having a look at what others are doing.
:idea: Please read the FAQ and How to Request Help.
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Re: Exclude name in txt file.

Post by TehJonny »

I am an absolute novice when it comes to this kind of programming thing I have no idea how to do what I want to do, I tried searching for filter but cannot find anything like what I want?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

Something like this:

('/path/to/text/file' as File).text.contains(n)
:idea: Please read the FAQ and How to Request Help.
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Re: Exclude name in txt file.

Post by TehJonny »

Is there a away to add multiple shows to this function:

Code: Select all

--filter "n != /Doctor Who/"
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

You wanted a solution with an external text file right? I just gave you that:

Check if text file contains the show name:

Code: Select all

('/path/to/text/file' as File).text.contains(n)


Maybe this is more easy to understand:

Check if text file contains a line that exactly matches the show name, and then only include those:

Code: Select all

readLines('D:/include.txt').contains(n)
Check if text file contains a line that exactly matches the show name, and then only exclude those:

Code: Select all

!readLines('D:/exclude.txt').contains(n)

* Make sure that the text file you read text from does not begin with a BOM marker. That would make the first line not work.
:idea: Please read the FAQ and How to Request Help.
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Re: Exclude name in txt file.

Post by TehJonny »

but then how do I add this to the utorrent run program I already have?

Code: Select all

filebot -script fn:amc --output "D:/Jonny's Stuff" --action copy --conflict auto -non-strict --log-file amc.log --def unsorted=y music=y artwork=n clean=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D" --def "seriesFormat=/TVShows/{n}\{'Season '+s}\{n} - {sxe} - {t}" --filter "n != /The Magicians/"
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

Exactly the same way as any other filter option...

You have:

Code: Select all

--filter "n != /The Magicians/"
You want:

Code: Select all

--filter "!readLines('D:/exclude.txt').contains(n)"
:idea: Please read the FAQ and How to Request Help.
TehJonny
Posts: 19
Joined: 13 Feb 2016, 00:45

Re: Exclude name in txt file.

Post by TehJonny »

Code: Select all

Run script [fn:amc] at [Sat Feb 20 22:06:35 GMT 2016]
Parameter: xbmc = 192.168.1.18
Argument: C:\Users\Administrator\Desktop\Media
ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unexpected token: s @ line 1, column 22.
   !readLines('D:/Jonny's Stuff/Downloads/exclude.txt').contains(n)
                        ^

1 error

Input: C:\Users\Administrator\Desktop\Media\The.Magicians.S01E05.720p.HDTV.x264-AVS - Copy.mkv
Group: [tvs:the magicians] => [The.Magicians.S01E05.720p.HDTV.x264-AVS - Copy.mkv]
ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script9.groovy: 1: unexpected token: s @ line 1, column 22.
   !readLines('D:/Jonny's Stuff/Downloads/exclude.txt').contains(n)
                        ^

1 error

Finished without processing any files
Failure (°_°)


Any idea about this?

Also I cant seem to get the Update Kodi function to work???

I am running Kodi on a NVIDIA SHEILD TV BOX if that makes a difference?
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

Don't use paths with special characters like ' if you don't know how to correctly escape those characters...

If you must have this path, then triple quotes will make this work:

Code: Select all

'''D:/Jonny's Stuff/Downloads/exclude.txt'''
:idea: Please read the FAQ and How to Request Help.
sheveron
Posts: 1
Joined: 26 Apr 2016, 04:45

Re: Exclude name in txt file.

Post by sheveron »

Hi.

I've had problem with filter argument. I tried to use it as you suggested

Code: Select all

--filter "!readLines('f:/exclude.txt').contains(n)"
but script kept throwing exceptions on me

Code: Select all

ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script10.groovy: 1: unexpected char: 0xFFFF @ line 1, column 27.
   /exclude.txt').contains(n)
I've spent all night trying to figure what is wrong. Even started digging into FileBot sources for clues.
But i could not find why it wasnt working.

Turned out it was all windows fault...
I'm using FileBot in bat script and iterating through files in for loop

Code: Select all

	for /r %%i in (*.*) do (
		set "Filename=%%~nxi"
		if {%Path1:~-1,1%}=={\} (set "Result=%Path1%!Filename!") else (set "Result=%Path1%\!Filename!")
		"c:\Program Files\FileBot\filebot.exe" -script fn:amc --filter "!readLines('f:/exclude.txt').contains(n)" --output "f:" --log-file "f:\amcbt.log" --action test --conflict override -non-strict --def excludeList=amc-input.txt artwork=y subtitles=ru plex=localhost:ZwdywpegcQDhk4mWGVjV "seriesFormat=f:/TVShows/{n}/{'Season '+s}/{n.space('.')}.{'s'+s.pad(2)}e{e.pad(2)}.{t.space('.')}" "movieFormat=f:/Movies/{ny}/{n.upperInitial().space('.')}.{y}.{source}.{vc}" "musicFormat=f:/Music/{n}/{fn}" "ut_dir=!Result!" "ut_kind=multi" "ut_title=!Filename!" --lang ru
	)
For that script to work i had to enable extensions

Code: Select all

setlocal enableextensions enabledelayedexpansion
You might notice !Filename! instead of %Filename%.

Yeah, so, windows interpreted exclamation mark in

Code: Select all

!readLines('f:/exclude.txt').contains(n)
as start point for variable and screwed up whole line...

So speaking of escaping, you also might need to escape ! with ^ if you have extensions enabled in script.
Maybe this info will save someones night someday.

Fixed filter now looks like this

Code: Select all

--filter "^!readLines('f:/exclude.txt').contains(n)"
P.S. I was also trying to exclude old The Magicians show :)
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exclude name in txt file.

Post by rednoah »

1.
You could have learned basic Groovy in that amount of time... CMD is to be avoided at all times.


2.
Best to pass complex arguments via text files:

Code: Select all

--filter @F:/filter.txt
filter.txt

Code: Select all

!readLines('F:/exclude.txt').contains(n)
@see viewtopic.php?f=3&t=3244
:idea: Please read the FAQ and How to Request Help.
Post Reply