This question has been asked a lot on stackoverflow, but I can\'t seem to be able to make it work. Any hints appreciated. Here is a text file (extension .mpl) containing offendi
You defined delims=
, that's a bad idea if you want to preserve your lines, as it splits after the first space.
You should change this to FOR /F "tokens=* delims=" ...
.
Your echo !str! >> testCleaned.mpl
will always append one extra space to each line, better use echo(!str!>>testCleaned.mpl
.
You will also lose all empty lines, and all exclamation marks in all lines.
You could also try the code of Improved BatchSubstitute.bat