Page 1 of 1
How to replace ( and ) in a script?
Posted: 03 May 2020 16:07
by Anthraquinone
Stuck indoor I thought I would try to learn XYplorers script language and perhaps some regex. Just for something to do. My first attemps worked OK but then I wanted to rename a ebook file with a name like
FILENAME (epub).epub
I can remove the epub inside he brackets but how do I remove the string (epub) including the brackets
rename s, "(epub)/";
Does not work. I assume that the brackets are characters that have a special meaning in the script language. I cannot fine this info anywhere.
AQ
Re: How to replace ( and ) in a script?
Posted: 03 May 2020 17:28
by highend
Mh, it should work. It doesn't even in a fresh instance?
There are special chars, like "[" (a range) that in some cases need to be escaped but parenthesis aren't normally of that type
This one would remove all surrounding spaces as well...
rename r, " *\(epub\) * > ";
Re: How to replace ( and ) in a script?
Posted: 03 May 2020 17:32
by serendipity
Hello,
That exact script (rename s, "(epub)/") seems to be working for me when I try it from menu Scripting | Run Script. Where exactly are you trying it from?
Re: How to replace ( and ) in a script?
Posted: 04 May 2020 00:12
by Anthraquinone
Thank you for the quick replies.
Both of your suggestions work OK as does the original one I written. I had closed the PC down and had to reopen it to try these. That may have cleared something out of the system. Computers - will they ever catch on?
I will continue working my way through the script language help file to see what else I can do with them. I find that is the best way for me to learn.
I will start be working out how
rename r, " *\(epub\) * > ";
workd. I may be back with some more questions though.
AQ
Re: How to replace ( and ) in a script?
Posted: 04 May 2020 00:31
by highend
Please, if you post any code, embed it in code or inline code tags. Far easier to read. The little toolbar above the editor window contains both of them