How to replace ( and ) in a script?

Discuss and share scripts and script files...
Post Reply
Anthraquinone
Posts: 21
Joined: 08 May 2013 23:44

How to replace ( and ) in a script?

Post 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

highend
Posts: 13277
Joined: 06 Feb 2011 00:33

Re: How to replace ( and ) in a script?

Post 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\) * > ";
One of my scripts helped you out? Please donate via Paypal

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: How to replace ( and ) in a script?

Post 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?

Anthraquinone
Posts: 21
Joined: 08 May 2013 23:44

Re: How to replace ( and ) in a script?

Post 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

highend
Posts: 13277
Joined: 06 Feb 2011 00:33

Re: How to replace ( and ) in a script?

Post 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
One of my scripts helped you out? Please donate via Paypal

Post Reply