Matching file name with space in it

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Matching file name with space in it Tue Feb 06, 2018 10:08 pm • by jormsby
OK, I'm sure this has been asked and answered before but I can not find it.

Trying to remove any characters after a Season and Episode designation for some tv shows. To do so, I am using "Name" "Matches" and set up the some 'Custom Text' as follows:

"•Show Name" = … (anything)
"•Season" = 11 (two single digits)
"•Episode" = 11 (two single digits)
"•Remainder" = … (anything)

The intent is to rename the file without the "•Remainder" part. To do so, I look for the Series and Episode numbers and segregate anything after that.

I put them together as *Show Name+S+•Season+E+•Episode+•Remainder (note I don't actually use the '+', I am just using them to show the different 'parts')

I am trying to recognize something like "S01E05" and then strip off the remainder. This works fine as long as there is not a space between the Season number (01 in the example) and the letter 'E'.

So "S01E05" is matched but "S01 E05" is not.

Prior to realizing that I had files that had a space between the Season and Episode, I was using a custom text match of "S11E11" (i.e. this is the letter 'S' followed by two of the hazel single digit placeholders then the letter 'E' followed but two more single digit placeholders).

I tried to add an 'if any' second match but 'I can not figure out how to get the rule to also match if there is a space between them.

So, I can get "24 (Legacy) - S01E01 - 12.00 Noon – 1.00 PM XYZ.mkv" to be renamed as "24 (Legacy) - S01E01.mkv" as desired

But "24 (Legacy) - S01 E01 - 12.00 Noon – 1.00 PM XYZ.mkv" will not match (space between S01 and E01)

Any insight would be appreciated.
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Wed Feb 07, 2018 11:34 am • by Mr_Noodle
Can you post your rule? You'll need to use a third party image hosting service for images to appear here. If you have Dropbox, for instance, you can use that to host the image and share the link.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Matching file name with space in it Wed Feb 07, 2018 7:07 pm • by jormsby
Here is a link.

The •Space is "…" (i.e. Anything)

Let me know if you need anything else.

https://tppr.me/zojKV
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Thu Feb 08, 2018 11:03 am • by Mr_Noodle
You may want to just use a space instead of a custom attribute for the space. What does the preview show?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Matching file name with space in it Thu Feb 08, 2018 3:32 pm • by jormsby
I originally tried a space instead of the custom attribute. I will try send you the "preview" this evening. The software is on my home computer so don't have access during the weekdays.
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Thu Feb 08, 2018 10:21 pm • by jormsby
Mr_Noodle wrote:You may want to just use a space instead of a custom attribute for the space. What does the preview show?



Is one of these what you are looking for?

https://tppr.me/RoEtS

https://tppr.me/2eKZL
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Fri Feb 09, 2018 11:34 am • by Mr_Noodle
Thanks for that. What are •Show Name and •Remainder set to match? It seems that neither pattern is matching so you need to rework both patterns in this case.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Matching file name with space in it Fri Feb 09, 2018 4:02 pm • by jormsby
•Show Name and •Remainder are both 'anything'.

Just as a test, I renamed one of the files to remove the space between the Season number and the Episode number and the rule matched for that one file. I did not modify the rule in any way. See below.

https://tppr.me/vMeij

I may be going about this in the wrong way but what I am attempting to do is to strip off any part of the file name that comes after either "SxxEyy" or "Sxx Eyy" where xx and yy are the two digit Series number and Episode number respectively. So, a file by the name of from:

"My.Favorite.Show.S03E12.AnnoyingLocationAndFileSizeInfo.mkv"

to

"My.Favorite.Show.S03.E12.mkv"
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Sat Feb 10, 2018 1:45 am • by jormsby
Sorry this is long.

OK, done some more investigating and seeing something odd. First I have created three different rules. I am using the “If any of the following conditions are met” setting. I have also created some custom text items. First, I have created two custom text objects and both of these are used in all three rules. They are as follows:

•Name of Show; This is set to ‘Anything’ and is the first item in each rule
•Remainder; This is set to ‘Anything’ and is the last item in each rule.

Now the rule specific custom text items . For each rule, I tried to use different ways to represent the following: SxxEyy where ‘S’ is the letter S and ‘E’ is the letter E. The xx and yy represent numbers. Each of the following are placed between the •Name of Show and the •Remainder custom text items.


First. Rule Custom Text:

•Season; which is ‘Number’
&
•Episode; which is a ‘Number’

Second Rule Custom Text:

•Season & Episode; which is the letter ‘S’ followed by the Number attribute then the letter ‘E’ followed by another Number attribute.

Third Rule Custom Text:

•SSeason; which is the letter ‘S’ followed by the Number attribute
&
•EEpisode which is the letter ‘E’ followed by the Number attribute


So, essentially I have tried three different methods to represent the “SxxEyy” I mentioned above. They are (without the quotes):

Rule 1: “S”•Season”E”•Episode

Rule 2: •Season & Episode

Rule 3: •SSeason•EEpisode


I then played around with inserting a space (using the space bar) into each of these rules to see if they would match any files that had a space between the Season number and the ‘E’ in the file name. In other words, “Sxx Eyy” instead of “SxxEyy”.

For Rule #1 it was between the •Season and the letter ‘E’
For Rule #2 it was inserted within the •Season & Episode custom text attribute
For Rule #3 it was inserted between •SSeason & •EEpisode

Here is what I found.

If all three rules contained the space, then all three would match a file name that contained the space and none of them would match a file without the space (exactly what I would expect).

If I removed the space from only Rule #1 and compared a file without the space, then only rule #1 would match (again, what I would expect)

If I removed the space from only Rule #1 (as above) and compared a file that did have the space, none of the rules would match. (this is not expected). I cannot see why rules #2 & #3 did not match.

I then did the opposite (i.e. Rule #1 with space and 2 & 3 without space).

Comparing against a file with the space, #1 matched but 2 & 3 did not (expected).

Comparing against a file without the space, none of them matched (unexpected)


Next step:

Rule #1 & #2 now have the space but Rule #3 does not.

Compare them against a file name without the space and #1 & #2 match and #3 does not. (Exactly what I would expect)

Compare them against a file name with the space and none of them match. (not what I would expect).


So, what it appears is that if the first rule matches the others and it also matches the file, they all show as a match. However, if the first rule does not match but the other two do, it shows all three as not matching.

It is almost like not receiving a match with the first rule blocks any remaining rule.

Any ideas?
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Mon Feb 12, 2018 11:58 am • by Mr_Noodle
Are we talking about rules or multiple conditions within one rule? Also, what happens if you re-order them?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Matching file name with space in it Mon Feb 12, 2018 7:11 pm • by jormsby
Mr_Noodle wrote:Are we talking about rules or multiple conditions within one rule? Also, what happens if you re-order them?



OK, looks like I was using the wrong terminology. First, I should have said I had one rule that contained multiple 'conditions'. Each condition was an attempt at doing the same thing, just with custom text attributes structured a little differently in each one.

I think in all my testing, I got confused :roll: . It seems that I was playing with different attributes to get it to work and instead of the (1)(1) (two single digits) as the attribute, I had changed them to the number attribute (123). In that configuration, and having two identical conditions in the rule with the exception of the added space in one, I was getting odd behavior. Only a file name with the space would match, no mater which condition was first in the rule.

Anyway, I copied that rule but changed the •Season and •Episode attributes from (123) to (1)(1). This seems to be working

So, what was probably throwing me was the confusing results when using the (123) instead of the (1) attribute.

I think I just got myself wrapped around the axle. Thank you for your time. I'm sure I will have more questions. :wink:
jormsby
 
Posts: 27
Joined: Mon Oct 13, 2014 7:04 pm

Re: Matching file name with space in it Tue Feb 13, 2018 11:18 am • by Mr_Noodle
Glad you have it sorted out. Also, it might be better to email in to support should you have more problems as you can then attach your rules for me to check out directly.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support