2itibd: I love to try&learn, however this specific task (search&replace) is really hard-to-achieve with internal commands (I mean it is not worth trying)... As you can see on Iceman example, it can be performed, however I thing using external utility for this task is much better and error-prone. I know this is not related to your problem, however this is the method I am something implementing search&replace operations= In batches you can implement this syntax: Set var=%var:searchfor=replace% Like for example Set test=1,2,3 Set test=%test:3=1% The variable %test% will now have values 1,2,1... Maybe you find it useful sometime. If you are interested in advanced batch scripting, check my blog