Multiple pattern matches on filename

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
doogienz
Posts: 2
Joined: 08 Mar 2017, 00:07

Multiple pattern matches on filename

Post by doogienz »

Hi there,

I've been googling this forum and also the groovy syntax, but can't find an example that matches.

I've trying to move files based on filenames, in this case 4K files. I want to match on 4K/2160p in the filename, but can't work out the syntax to do this, currently I'm using this portion:

"movieFormat={fn =~ /2160p/ ? '/4K' : 'Movies'}

Which moves if it matches 2160p to the directory /4k (under the main directory).

What is the conditional separator? How do I match either 2160p or 4K.
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

Thanks for the post! Before a real human comes by, please make sure your report has all the following points checked:
  • What are you trying to do achieve? What's not working? What have you tried so far?
  • Include screenshots, logs or filenames (i.e. demonstrate the issue)
  • Include basic information (i.e. sysinfo output)
:idea: Please read How to Request Help and Fix Problems, Report Bugs, Get Features
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

You can use regular expressions to match multiple patterns.

Though, instead of checking the filename, I'd use mediainfo to check the video resolution:

Code: Select all

{dim[1] >= 2160 ? 'UHD' : 'HD'}
:idea: Please read the FAQ and How to Request Help.
doogienz
Posts: 2
Joined: 08 Mar 2017, 00:07

Re: Multiple pattern matches on filename

Post by doogienz »

Thanks very much :)
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

i dont understand the answer, maybe can help me...

Code: Select all

filebot -script 'fn:amc' /volume1/Download --output '/volume1/video/Folder1' --action move -non-strict --lang de --def 'ut_label=movie' 'music=y' 'unsorted=y' 'artwork=y' 'skipExtract=y' 'deleteAfterExtract=y' 'movieFormat={file.parentFile.name}/{n} ({y})' --log WARNING --log-file '/volume1/Download/FileBotMovie.log'
Folder for normal Movies = Folder1 (/volume1/video/Folder1)
Folder for 4k/UH Movies = Folder2 (/volume1/video/Folder1/Folder2)

can please help to find the right command for my usecase?
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

Code: Select all

{dim[1] >= 2160 ? 'UHD' : 'HD'}/{plex}
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

thanks rednoah for fast answering, but i dont know where coming your paste in my command line...

filebot -script 'fn:amc' /volume1/Download --output '/volume1/video/Folder1' --action move -non-strict --lang de --def 'ut_label=movie' 'music=y' 'unsorted=y' 'artwork=y' 'skipExtract=y' 'deleteAfterExtract=y' 'movieFormat={dim[1] >= 2160 ? 'UHD' : 'HD'}/{plex}{file.parentFile.name}/{n} ({y})' --log WARNING --log-file '/volume1/Download/FileBotMovie.log'

is wrong?
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

PayPal wrote:Total amount:
€1,00 EUR
Fee amount:
-€0,38 EUR

Net amount:
€0,62 EUR
I'm not quite sure how I should feel about 62 cent donations... :lol:

Here's a helpful link though: viewtopic.php?f=4&t=1899
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

This is unfortunately as helpful as google.com :(
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

google.com is considered to be very helpful. :lol:

Q: If you use '...' to mark the beginning and the end of the argument, what happens if ' occurs in the argument value?
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

you mean Escape Arguments ?

Code: Select all

filebot -script 'fn:amc' /volume1/Download --output '/volume1/video/Folder1' --action move -non-strict --lang de --def 'ut_label=movie' 'music=y' 'unsorted=y' 'artwork=y' 'skipExtract=y' 'deleteAfterExtract=y' 'movieFormat={dim[1] >= 2160 ? \'Folder1/Folder2\' : \'Folder1\'}/{file.parentFile.name}/{n} ({y})' --log WARNING --log-file '/volume1/Download/FileBotMovie.log'
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

Do I look like a command interpreter? Just hit ENTER and then look at the output, then fix whatever it says, then rinse and repeat until it works.
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

sh: -c: line 0: syntax error near unexpected token `('
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

It looks like you've been using FileBot Node. Why don't you keep using FileBot Node?

Use the format as is in the text box, and then learn from how FileBot Node correctly escapes your format:

Code: Select all

{dim[1] >= 2160 ? 'UHD' : 'HD'}/{plex}
PS: I don't have time for this kind step-by-step support. I recommend using the GUI. The CLI is for folks that don't mind figuring things out for themselves.
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

thanks for "very excellent support"
User avatar
rednoah
The Source
Posts: 23930
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Multiple pattern matches on filename

Post by rednoah »

You got your 62 cent worth of support.

Besides, I provide excellent support for filebot, and not bash. If you can't be bothered to learn how to use the command-line, then you won't be able to use the command-line:
rednoah wrote:Make sure you escape and quote your cmdline arguments correctly. I will not fix your broken cmdline call for you.
@see viewtopic.php?f=5&t=1868
:idea: Please read the FAQ and How to Request Help.
horst123789
402
Posts: 18
Joined: 07 Feb 2015, 12:15

Re: Multiple pattern matches on filename

Post by horst123789 »

if i use:

Code: Select all

filebot -script 'fn:amc' /volume1/Download --output '/volume1/video/Folder1' --action move -non-strict --lang de --def 'ut_label=movie' 'music=y' 'unsorted=y' 'artwork=y' 'skipExtract=y' 'deleteAfterExtract=y' 'movieFormat={dim[1] >= 2160 ? 'Folder1/Folder2' : 'Folder1'}/{file.parentFile.name}/{n} ({y})' --log WARNING --log-file '/volume1/Download/FileBotMovie.log'
filebot can successfull starting, but the sorting/movie is totally wrong... i think the {dim[1] >= 2160 ? 'Folder1/Folder2' : 'Folder1'} is on wrong postion in command line... filebot node dont help, only support 1 working folder
Post Reply