Page 1 of 1

Multiple pattern matches on filename

Posted: 08 Mar 2017, 00:13
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.

Re: Multiple pattern matches on filename

Posted: 08 Mar 2017, 06:39
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

Re: Multiple pattern matches on filename

Posted: 08 Mar 2017, 06:52
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'}

Re: Multiple pattern matches on filename

Posted: 08 Mar 2017, 21:24
by doogienz
Thanks very much :)

Re: Multiple pattern matches on filename

Posted: 11 Mar 2017, 14:16
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?

Re: Multiple pattern matches on filename

Posted: 11 Mar 2017, 14:42
by rednoah

Code: Select all

{dim[1] >= 2160 ? 'UHD' : 'HD'}/{plex}

Re: Multiple pattern matches on filename

Posted: 11 Mar 2017, 15:22
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?

Re: Multiple pattern matches on filename

Posted: 12 Mar 2017, 20:55
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

Re: Multiple pattern matches on filename

Posted: 12 Mar 2017, 21:02
by horst123789
This is unfortunately as helpful as google.com :(

Re: Multiple pattern matches on filename

Posted: 12 Mar 2017, 21:26
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?

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 07:52
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'

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 08:41
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.

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 08:57
by horst123789
sh: -c: line 0: syntax error near unexpected token `('

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 09:03
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.

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 09:11
by horst123789
thanks for "very excellent support"

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 11:27
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

Re: Multiple pattern matches on filename

Posted: 13 Mar 2017, 20:55
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