sample
qubit3265
batchfile
a year ago
954 B
3
Indexable
Never
@echo off setlocal enabledelayedexpansion :: Set the path to the input file set "inputFile=your_input_file.txt" :: Set the path to the temporary output file set "outputFile=temp_output_file.txt" :: Clear output file if exists echo.> %outputFile% :: Read the input file line by line for /f "usebackq delims=" %%a in ("%inputFile%") do ( set "line=%%a" :: Search for the pattern echo.!line! | findstr /r /c:"programfolder=[A-Z\\:]*" >nul if !errorlevel! == 0 ( for /f "tokens=2 delims==" %%b in ("!line!") do ( set "folderPath=%%b" :: Compare with the environment variable if "!folderPath!" neq "%ProgramLocation%" ( set "line=programfolder=%ProgramLocation%" ) ) ) :: Write the line to the output file echo.!line! >> %outputFile% ) :: Replace the original input file with the updated output file move /y %outputFile% %inputFile% endlocal