BatchSubstitute.bat 695 B

12345678910111213141516171819
  1. @echo off
  2. REM -- COPYRIGHT ==> http://www.dostips.com
  3. REM -- Prepare the Command Processor --
  4. SETLOCAL ENABLEEXTENSIONS
  5. SETLOCAL DISABLEDELAYEDEXPANSION
  6. ::BatchSubstitude - parses a File line by line and replaces a substring"
  7. ::syntax: BatchSubstitude.bat OldStr NewStr File
  8. :: OldStr [in] - string to be replaced
  9. :: NewStr [in] - string to replace with
  10. :: File [in] - file to be parsed
  11. if "%*"=="" findstr "^::" "%~f0"&GOTO:EOF
  12. for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
  13. set "line=%%B"
  14. if defined line (
  15. call set "line=echo.%%line:%~1=%~2%%"
  16. for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
  17. ) ELSE echo.
  18. )