@echo off & setlocal enabledelayedexpansion @REM 需要被替换的字符串,注意字符串前后不加“”,支持空格 set var1={ this.baseAttributes = []; for(let _ele of _json_.baseAttributes) { let _e; { _e = []; for(let _ele of _ele) { let _e; _e = new TbGEntity.TAttributeValue(_ele); _e.push(_e);}}; this.baseAttributes.push(_e);}} @REM 替换成什么内容,此处是批处理当前路径 set var2={ this.baseAttributes = []; for(let _ele of _json_.baseAttributes) { let _e; { _e = []; for(let _ele of _ele) { let _e; _e = new TbGEntity.TAttributeValue(_ele); _e.push(_e);}}; this.baseAttributes.push(_e);}} for /r %%i in (JisolGameCocos\assets\script\config\data\schema.ts) do ( echo %%i @REM 读取a.txt所有内容 for /f "eol=* tokens=*" %%j in (%%i) do ( @REM 设置变量a为每行内容 set a=%%j @REM 如果该行有var1,则将其改为var2 set "a=!a:%var1%=%var2%!" echo !a! @REM 把修改后的全部行存入$ echo !a!>>$ ) @REM 用$的内容替换原来a.txt内容 move $ %%i ) pause