Page 1 of 1

Replacing/removing ! in a batch file (with answer)

PostPosted: Wed Jun 27, 2018 9:38 pm
by 12characters
I needed to remove exclamations marks from file names. After reading an answer somewhere on this forum, it appears that exclamations (as well as ampersands &) need to be escaped with ^.

Unfortunately the batch processor grabs the caret, so the answer is to use 2 of them, like so:

Code: Select all
BRC32 /PATTERN:* /REPLACECI:^^!:CharlieXCX /EXECUTE


I hope this saves someone somewhere from frustration.

Re: Replacing/removing ! in a batch file (with answer)

PostPosted: Thu Mar 07, 2019 8:35 pm
by bru
Exclamations should only need 'double-escaping' if delayed !variable! expansion is enabled.
In that case, cmd grabs the 1st-caret, so a 2nd is needed, but only for exclamations.
Thanks!