How to check filepath with a space in it?

Any questions? Need some help?
Post Reply
iAmKoinu
Posts: 4
Joined: 19 Oct 2018, 14:06

How to check filepath with a space in it?

Post by iAmKoinu » 03 Nov 2018, 22:55

Windows 10
Filebot 4.8.2
Installed from your website through the link that came in the email with my 1-year license.
Sysinfo =

Code: Select all

FileBot 4.8.2 (r5789)
JNA Native: 5.2.2
MediaInfo: 18.05
7-Zip-JBinding: 9.20
Chromaprint: 1.4.2
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2018-10-05 (r536)
Groovy: 2.5.1
JRE: Java(TM) SE Runtime Environment 10.0.2
JVM: 64-bit Java HotSpot(TM) 64-Bit Server VM
CPU/MEM: 4 Core / 3 GB Max Memory / 203 MB Used Memory
OS: Windows 10 (amd64)
Package: MSI
License: FileBot License T1077 (Valid-Until: 2019-10-31)

I think that is all the info that I need to give right?

So my problem is that I can't figure out how to get the if-else command to accept a filepath that has a space in it.
I have a folder where all my "currently complete, but not ready for Plex" media goes named "Media (Complete)"

what I'm currently using (which works):

Code: Select all

{file =~ /(Complete)/ ? {f[0..3]} : {folder}}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()} ({y})/{episode.special ? 'Specials/' : 'Season '+s.pad(2)}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()}.{y}.{order.airdate.s00e00}{file =~ /Anime/ ? '.#'+absolute.pad(4) : null}.{episode.title.colon(" - ").slash("-")}.[{airdate.format("MMM-dd-yyyy")}]
This code also works:

Code: Select all

{file =~ /Media/ ? {f[0..3]} : {folder}}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()} ({y})/{episode.special ? 'Specials/' : 'Season '+s.pad(2)}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()}.{y}.{order.airdate.s00e00}{file =~ /Anime/ ? '.#'+absolute.pad(4) : null}.{episode.title.colon(" - ").slash("-")}.[{airdate.format("MMM-dd-yyyy")}]
but I can't figure out how to make this work (which is what I want, as it will prevent any mismatches with the if-statement.

Code: Select all

{file =~ /Media (Complete)/ ? {f[0..3]} : {folder}}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()} ({y})/{episode.special ? 'Specials/' : 'Season '+s.pad(2)}/{series.name.colon(" - ").slash("-").replaceTrailingBrackets()}.{y}.{order.airdate.s00e00}{file =~ /Anime/ ? '.#'+absolute.pad(4) : null}.{episode.title.colon(" - ").slash("-")}.[{airdate.format("MMM-dd-yyyy")}]
Anybody have any idea?

P.S. I've included screenshots of a test folder I set up for this exact problem.

Screenshot 1 - Folder naming scheme:
https://snag.gy/pujTnR.jpg

Screenshot 2 - Code I Want, But Isn't Working:
https://snag.gy/y3A2lx.jpg

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

Re: How to check filepath with a space in it?

Post by rednoah » 05 Nov 2018, 15:36

I see. So you're saying this particular bit doesn't work as expected?

Code: Select all

file =~ /Media (Complete)/

Note that file =~ /.../ expects a Regular Expression, and not a String Literal value, meaning (...) is interpreted as Regex capturing group:
https://regexr.com/


This would be a solution:

Code: Select all

file =~ /Media \(Complete\)/
or

Code: Select all

file =~ /Media [(]Complete[)]/

Test Case:

Code: Select all

{'Media (Complete)' =~ /Media [(]Complete[)]/ ? 'MATCH' : 'NO MATCH'}
:idea: Please read the FAQ and How to Request Help.

iAmKoinu
Posts: 4
Joined: 19 Oct 2018, 14:06

Re: How to check filepath with a space in it?

Post by iAmKoinu » 13 Nov 2018, 07:10

rednoah wrote:
05 Nov 2018, 15:36
I see. So you're saying this particular bit doesn't work as expected?

Code: Select all

file =~ /Media (Complete)/

Note that file =~ /.../ expects a Regular Expression, and not a String Literal value, meaning (...) is interpreted as Regex capturing group:
https://regexr.com/


This would be a solution:

Code: Select all

file =~ /Media \(Complete\)/
or

Code: Select all

file =~ /Media [(]Complete[)]/

Test Case:

Code: Select all

{'Media (Complete)' =~ /Media [(]Complete[)]/ ? 'MATCH' : 'NO MATCH'}
Well, there you go. thanks for that! now the code works pretty much exactly how I want it to! thanks so much! :)

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests