bat替换文件中的字符串

@echo off

set strOld=-t 1
set /a cpu=%number_of_processors%-1
set strNew=-t %cpu%
set file=%~dp0start.bat

setlocal enabledelayedexpansion

for /f "tokens=*" %%j in (%file%) do (
	set "tmp=%%j"
	if not !tmp!.==. (
	  set "tmp=!tmp:%strOld%=%strNew%!"
	  echo !tmp!>>temp.txt
	)
)
move temp.txt %file%
    


你可能感兴趣的:(开发问题解决集)