:: MrNetTek :: eddiejackson.net/blog :: 3/25/2020 :: free for public use :: free to claim as your own @echo off setlocal enabledelayedexpansion :: variables set Input=Text.tmp set Output=Text.dat set strOld=9F1AE7B34381DFD1111 set strNew=9F1AE7B34381DFD9999 :: prep temp file move "%Output%" "%Input%" if exist "%Output%" del /q "%Output%" :: search for /f "tokens=1* delims=[]" %%a in ('type "%Input%" ^| find.exe /n /v ""') do ( set strLine=%%b :: replace if defined strLine set strLine=!strLine:%strOld%=%strNew%! echo.!strLine! >>"%Output%" echo.!strLine! ) :: cleanup del /q %Input% set %Output%= set %Input%= set %strOld%= set %strNew%= exit /b 0