bat/cmd处理文件内容替换 乱码解决
bat实现替换bootstrap.yml中的端口号
: 替换bootstrap.yml中的端口号
set bootstrap_file=project_name\src\main\resources\bootstrap.yml
set port_old=8080
set port=80
for /f "tokens=*" %%i in ('dir /b /s /a:-d %bootstrap_file%') do (
powershell -Command "(gc %%i -encoding UTF8 ) -replace '%port_old%', '%port%' | Out-File -Encoding UTF8 %%i"
)
参考
Powershell Get-Content 编码设置
CMD/BAT 批处理方式进行文件的字符串搜索替换,完美解决方案