Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: https://stackoverflow.com/questions/23075953/batch-script-to-find-and-replace-a-string-in-text-file-without-creating-an-extra/23076141
- @echo off
- setlocal enableextensions disabledelayedexpansion
- set "search=%1"
- set "replace=%2"
- set "textFile=file.txt"
- for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
- set "line=%%i"
- setlocal enabledelayedexpansion
- >>"%textFile%" echo(!line:%search%=%replace%!
- endlocal
- )
Advertisement
Add Comment
Please, Sign In to add comment