Correct Way to Use --file-filter Option?

Any questions? Need some help?
Post Reply
HarryMuscle
Posts: 34
Joined: 06 Jan 2022, 22:40

Correct Way to Use --file-filter Option?

Post by HarryMuscle »

I'm trying to use the --file-filter option to only process (via the AMC script) files that are in folders matching a certain regex, but no matter what I try I always get the following error:

Code: Select all

Invalid usage: no input
Abort (×_×)
I even get this error with the following file filter that should allow everything:

Code: Select all

--file-filter "folder.name.match(/.+/)"
Also tried:

Code: Select all

--file-filter "folder.name =~ /.+/"
and I even tried:

Code: Select all

--file-filter "true"
but I always end up with the above error.

As soon as I remove the --file-filter option everything works correctly.

In case it matters, I'm running FileBot 4.9.4.

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

Re: Correct Way to Use --file-filter Option?

Post by rednoah »

:?: What's the complete command-line call? Are you passing any input folders or files?


e.g. list files in or below the current directory . and select files where the file path matches a specific keyword, and then print them with a specific custom format:

Code: Select all

$ filebot -mediainfo -r . --file-filter "f =~ /Earth/" --format "{fn}"
The.Man.from.Earth.2007
:idea: Please read the FAQ and How to Request Help.
HarryMuscle
Posts: 34
Joined: 06 Jan 2022, 22:40

Re: Correct Way to Use --file-filter Option?

Post by HarryMuscle »

rednoah wrote: 09 Feb 2022, 02:13 :?: What's the complete command-line call? Are you passing any input folders or files?


e.g. list files in or below the current directory . and select files where the file path matches a specific keyword, and then print them with a specific custom format:

Code: Select all

$ filebot -mediainfo -r . --file-filter "f =~ /Earth/" --format "{fn}"
The.Man.from.Earth.2007
I tried a few different command versions but it's basically this:

Code: Select all

filebot -script fn:amc /FileBot/Input --output /FileBot/Output --action move --conflict skip --def artwork=n --def movieFormat="{emby}" --file-filter "folder.name.match(/.+/)"
Does the order of the various options matter? Or is the issue possibly that --file-filter cannot be used with the AMC script?

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

Re: Correct Way to Use --file-filter Option?

Post by rednoah »

The order of arguments does not matter.


:idea: Note that you're not using -r so you're passing 1 input folder, which is presumably excluded by your --file-filter for some reason, and thus the amc script is called with no input arguments.


:idea: The amc script itself does accept folders as input, which it will then resolve for input files. But you want to pass an input folder, have filebot itself resolve the files inside, apply your --file-filter, and then pass the selected files onto your script.


tl;dr you're accidentally doing this:

Code: Select all

find /FileBot/Input -type f  -maxdepth 1 -exec filebot -script fn:sysenv {} +
instead of this:

Code: Select all

find /FileBot/Input -type f -exec filebot -script fn:sysenv {} +


:!: The amc script itself doesn't like it if you use -r because the amc script itself likes to interpret the input and decide what to do with it, so it's typically used with a single input folder. But if you selected the files, and then pass them on as arguments, then it'll work with that input file set as is.

e.g. compare and contrast:

Code: Select all

filebot -script g:"println args" .

Code: Select all

filebot -script g:"println args" . -r

Code: Select all

filebot -script g:"println args" . -r --file-filter f.video

Code: Select all

filebot -script g:"println args" . -r --file-filter "folder.name =~ /.+/"

Code: Select all

filebot -script g:"println args" . -r --file-filter "true"
:idea: The key thing to note is that FileBot will interpret input arguments and resolve them to a list of file paths before a script is called, kinda like find ... -exec filebot ... would collect files and then pass them as arguments when when filebot is executed.



EDIT:

I think I know what got you confused:

If you do this, then you'll be passing in the current folder as input argument:

Code: Select all

filebot -script g:"println args" .
But if you do --file-filter then you implicitly limit filebot to files within the given folder (non-recursive without -r) that match your file filter expression, excluding subfolders and files within those subfolders:

Code: Select all

filebot -script g:"println args" . --file-filter true
:arrow: So you need to use -r recursive mode to apply your --file-filter to either all files recursively in the given folder, or -d folder mode to apply your --file-filter to include / exclude sub-folders from the given folder. So without -r or -d if the folder passed as input contains no files and only folders, then that's zero file arguments, your file filter is never applied to anything, and zero file arguments are then passed to the script for processing.



EDIT 2:

If you're using the amc script and just need regular expression based excludes, then you'll want to use the script-specific --def ignore option, so the script itself can make the decision, and print log entires accordingly.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Correct Way to Use --file-filter Option?

Post by rednoah »

:arrow: :arrow: How to process only specific kinds of files? for help on the --file-filter option.

:arrow: :arrow: --filter and fine-tuning for help on the --filter option.
:idea: Please read the FAQ and How to Request Help.
Post Reply