We help IT Professionals succeed at work.

Need help creating a batch file to replace txt in txt file

I have a file that I need to change on 100 machines that tell what dir's to backup. I am looking for a bat file or vbs that I can push to change line 4 to this: INCLUDE "C:\Users\username\Documents\...\*"

EXCLUDE "C:\...\*"
INCLUDE "C:\Users\username\Desktop\...\*"
INCLUDE "C:\Users\username\Favorites\...\*"
INCLUDE "C:\Users\username\My Documents\...\*"
INCLUDE "C:\Users\username\AppData\Mozilla\...\*"
Watch Question

Neil RussellTechnical Development Lead

Why not just create 1 new copy of the file and copy it out to all PC's?


Because each file has unique node names
I've kept this all purpose find/replace script handyl. As the comment suggests, I got this from http://www.dostips.com

Direct URL to the attached script. - Please read limitations and usage examples. Should fit your requirements.

@echo off
REM -- Prepare the Command Processor --

::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
::          OldStr [in] - string to be replaced
::          NewStr [in] - string to replace with
::          File   [in] - file to be parsed
:$changed 20100115
:$source http://www.dostips.com
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
    set "line=%%B"
    if defined line (
        call set "line=echo.%%line:%~1=%~2%%"
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
    ) ELSE echo.

Open in new window