How can I chain two name changes in the title?

All about user-defined episode / movie / file name format expressions
Post Reply
pachuezama
Posts: 5
Joined: 04 Sep 2020, 08:35

How can I chain two name changes in the title?

Post by pachuezama »

Hi,

I want to change the characters ¿ and ? for ¡ and !. If I use t.replace('?', '!') it works fine, but I can't add the other change.... Any idea?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can I chain two name changes in the title?

Post by rednoah »

String.replace() yields a String value as a result, so you can chain them easily:

Code: Select all

'¿¡'.replace('¿', '?').replace('¡', '!')
:idea: Please read the FAQ and How to Request Help.
pachuezama
Posts: 5
Joined: 04 Sep 2020, 08:35

Re: How can I chain two name changes in the title?

Post by pachuezama »

Thanks.... but ....

t.replace('¿', '?').replace('¡', '!')?

t.'¿¡'.replace('¿', '?').replace('¡', '!')

Does not work for me....
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can I chain two name changes in the title?

Post by rednoah »

This will work:

Code: Select all

t.replace('¿', '?').replace('¡', '!')
Because this works:

Code: Select all

'test 1 ¿ 2 ¡'.replace('¿', '?').replace('¡', '!')
:idea: I'm using the constant String value '¿¡' for test purposes. t is a variable that is a String value, so it'll work the same.


:idea: If you were to provide a specific episode as example for testing, then I could have used your example for illustration purposes. But in absence of that, I had to show how it works using a constant String value to serve as test data. Please read How to Request Help for details.
:idea: Please read the FAQ and How to Request Help.
pachuezama
Posts: 5
Joined: 04 Sep 2020, 08:35

Re: How can I chain two name changes in the title?

Post by pachuezama »

I'm sorry, but for me doesn't work... here you have an exemple....

I have try with this one:

Code: Select all

D/{n.colon(' - ')} ({y})/{'Season '+s}/{n.colon(' - ')} - {s00e00} - {t.replace('¿', '?').replace('¡', '!')}

Code: Select all

Dexter - S03E12 - ¿Tomas a Dexter Morgan-.avi
Image

Image

I have try with only one ¿ or ? and then it's ok, but with the two characters I can´t

Any idea?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can I chain two name changes in the title?

Post by rednoah »

1.
As you can see in your screenshot, the first ¿ has been replaced with ? successfully:
Image



2.
However on Windows ? is not allowed in file paths, so if your custom format is generating invalid file paths, then FileBot help fix them up by stripping the ? away.

:idea: You may want to remove ¿? in your custom format so that FileBot doesn't have to ask you about it later:

Code: Select all

t.removeAll(/[¿?]/)


3.
This piece of code:

Code: Select all

{t.replace('¿', '?').replace('¡', '!')}
will generate this piece of text:

Code: Select all

?Tomas a Dexter Morgan?
You'll want to use this piece of code:

Code: Select all

t.removeAll(/[¿?]/).replace('¡', '!')
to generate this piece of text with ¿? remove to make the file name Windows-compatible:

Code: Select all

Tomas a Dexter Morgan
:idea: Please read the FAQ and How to Request Help.
pachuezama
Posts: 5
Joined: 04 Sep 2020, 08:35

Re: How can I chain two name changes in the title?

Post by pachuezama »

Hi, I have found the problem... I'm not explained very well....

{t.replace('¿', '¡').replace('?', '!')} will do what I want.... I tried it and all is OK..... that is change the ¿? characters for ¡!.....

Thanks for your help....
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can I chain two name changes in the title?

Post by rednoah »

Just change the replacement value accordingly then:

Code: Select all

{t.replace('¿', '¡').replace('?', '!')}
:idea: Please read the FAQ and How to Request Help.
pachuezama
Posts: 5
Joined: 04 Sep 2020, 08:35

Re: How can I chain two name changes in the title?

Post by pachuezama »

Many, many thanks.
Post Reply