Help with file filters

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
UKenGB
Posts: 49
Joined: 04 Jan 2017, 09:26

Help with file filters

Post by UKenGB »

So is everything between the quotes Groovy code?
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --filter and fine-tuning

Post by rednoah »

Yes. The --filter option expects a Groovy expression that yields a boolean value (any other return Object will be interpreted according to Groovy Truth) and expressions that fail are interpreted as if they were to return false.

Not passing --filter is functionally equivalent to passing --filter true.

The "..." are just necessary for correctly passing the Groovy expression to FileBot on the command-line.
:idea: Please read the FAQ and How to Request Help.
peatnik
Posts: 8
Joined: 31 Dec 2016, 12:48

Re: --filter and fine-tuning

Post by peatnik »

Is there a way to apply filters to the input sources, too?

I want to completely reprocess an entire library to change the naming scheme and it works very well except that it takes a long time because it needlessly processes files that already match the new naming scheme.
I would like to be able to say "if the input file matches this pattern, don't process it", ideally with regular expressions.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --filter and fine-tuning

Post by rednoah »

1.
If you're re-processing files that have already been named and tagged, then you can use --db xattr to read metadata from xattr (which is pretty much instant).

2.
If you're using Unix, then you can use find -exec or xargs and pass the files you want into the filebot call.
:idea: Please read the FAQ and How to Request Help.
peatnik
Posts: 8
Joined: 31 Dec 2016, 12:48

Re: --filter and fine-tuning

Post by peatnik »

Thanks for the quick response.

1)
I am processing files from Amazon Cloud Drive (S3) via rclone mount (FUSE) which does not allow setting xattrs. They can be read though, so I might try that.
Please correct me if i am wrong but from what I understand I would use
--db xattr -non-strict --filter "!n.contains(') [')"
to exclude a file like this "Title (Year) [Metainfo].ext"?

2) I don't think I can pass in the files individually because subtitles would not be renamed that way, would they? I have up to 10 subtitle files for some movies and to be correctly identified they need to have the same name as the movie, apart from the extension.
If it does work, however, i assume it would be inefficient or even dangerous because for that movie with 10 subtitles I'd be querying the MovieDB 10 times.
Again, please correct me if i'm wrong.

Regards

P.S.: While we are somewhat on the topic of cloud storage as source, I had to break the processing into parts because Amazon Cloud Drive places limits on how many files you can have open at any one time. Trying to process a folder with subfolders and a total of 5000-15000 items would hit that API limit and even take down the rclone mount so that I needed to remount. In addition, indexing everything at the very beginning causes a big up-front penalty that I need to pay everytime i restart the process and that penalty is magnified by the HTTP API overhead of accessing the cloud drive. Have you thought about optimizing open file access, e.g. by going strictly folder-by-folder? I had a quick glance at the code and it seems to me like you are not closing the files after using FileUtilities.
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: --filter and fine-tuning

Post by rednoah »

1.
{n} could be anything depending on the xattr. {fn} will always refer to the filename. I'd use --action test for testing on a small set of files.


2.
You should process all files in one go. You make 1 filebot call and pass all your files on the command-line. This is what find -exec ... + and xargs do for you.

@see viewtopic.php?f=3&t=4222

e.g.

Code: Select all

filebot -rename a.mp4 a.eng.srt a.zho.srt b.mp4 b.eng.srt b.zho.srt ...

3.
If you want to call filebot -rename for each folder, you can. It's probably a good idea to do things in more reasonable chunks. find -exec ... \; makes it easy to call filebot for each folder.


4.
Which method leaks file handles? Please include line numbers or copy and paste code snippets.
:idea: Please read the FAQ and How to Request Help.
Post Reply