Replacing values in .bat files

June 29, 2010 at 20:56:30
Specs: Windows XP
Hi all,

I have a few .bat files that has a pointer to a particular server.

I am trying to create a .bat script to change all these pointers to a new server.

These bat files are in the same folder. I need to change the server pointer "\\server123" to "\\server234"

Can anyone guide how to go about doing this bat script?


See More: Replacing values in .bat files

Report •

June 29, 2010 at 20:57:57
After changing it, they can use overwrite the .bat files in the same directory.

Appreciate any help..thanks alot.. guys

Report •

June 30, 2010 at 02:11:08
Beware: script not tested.

@echo off & setlocal EnableDelayedExpansion
cd /D Your Batch Directory
for %%i in (*.bat) do for /F "delims=" %%j in (%%i) do (
  set line=%%j
  if not "!line:\\server123=!"=="!line!" set line=!line:\\server123=\\server234!
  echo !line!>>
move *.new *.bat
:: End_Of_Batch

Report •
Related Solutions

Ask Question