Page 1 of 1
How can I chain two name changes in the title?
Posted: 04 Sep 2020, 09:06
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?
Re: How can I chain two name changes in the title?
Posted: 04 Sep 2020, 09:19
by rednoah
String.replace() yields a
String value as a result, so you can chain them easily:
Code: Select all
'¿¡'.replace('¿', '?').replace('¡', '!')
Re: How can I chain two name changes in the title?
Posted: 04 Sep 2020, 12:35
by pachuezama
Thanks.... but ....
t.replace('¿', '?').replace('¡', '!')?
t.'¿¡'.replace('¿', '?').replace('¡', '!')
Does not work for me....
Re: How can I chain two name changes in the title?
Posted: 04 Sep 2020, 13:25
by rednoah
This will work:
Code: Select all
t.replace('¿', '?').replace('¡', '!')
Because this works:
Code: Select all
'test 1 ¿ 2 ¡'.replace('¿', '?').replace('¡', '!')
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.
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.
Re: How can I chain two name changes in the title?
Posted: 05 Sep 2020, 07:07
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
I have try with only one ¿ or ? and then it's ok, but with the two characters I can´t
Any idea?
Re: How can I chain two name changes in the title?
Posted: 05 Sep 2020, 09:51
by rednoah
1.
As you can see in your screenshot, the first
¿ has been replaced with
? successfully:
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.
You may want to remove
¿? in your custom format so that FileBot doesn't have to ask you about it later:
3.
This piece of code:
Code: Select all
{t.replace('¿', '?').replace('¡', '!')}
will generate this piece of text:
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:
Re: How can I chain two name changes in the title?
Posted: 05 Sep 2020, 10:41
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....
Re: How can I chain two name changes in the title?
Posted: 05 Sep 2020, 11:46
by rednoah
Just change the replacement value accordingly then:
Code: Select all
{t.replace('¿', '¡').replace('?', '!')}
Re: How can I chain two name changes in the title?
Posted: 06 Sep 2020, 05:59
by pachuezama
Many, many thanks.