chcp 65001 @echo off & SetLocal EnableDelayedExpansion echo 正在清理git文件 @for /r . %%a in (.) do @if exist "%%a/.git" rd /s /q "%%a/.git" @echo git已经全部删除 set old=template Set /p new=请输入工程英文简称(如prevention): Set /p version=请输入onreal版本(如3.7.0): echo. echo 正在替换文件内容 :: 替换版本号 for /f %%i in ('dir /b /s /a:-d pom.xml') do ( powershell -Command "(Get-Content %%i -Encoding utf8) -replace '3.7.0-SNAPSHOT', '%version%' | Set-Content %%i -Encoding utf8" ) :: 将当前目录(包括子目录)下的所有 java 文本中的 template 替换为输入字符 for /f %%i in ('dir /b /s /a:-d *.java,pom.xml,*.yml,*.sql,*.txt,Dockerfile') do ( powershell -Command "(Get-Content %%i -Encoding utf8) -replace '%old%', '%new%' | Set-Content %%i -Encoding utf8" ) echo 替换文件内容完成 echo. echo 正在替换文件夹名 for /d /r %%i in (*.*) do ( set t=%%~ni set t=!t:%old%=%new%! if not exist "%%~dpi!t!" ren "%%i" "!t!" ) echo 替换文件夹名完成 echo. echo 正在替换文件名 for /f %%i in ('dir /a:-d /s /b *.java,pom.xml,*.yml,*.sql,*.txt') do ( set t=%%~ni set ext=%%~xi set t=!t:%old%=%new%! if not exist "%%~dpi!t!" ren "%%i" "!t!!ext!" 2>nul ) echo 替换文件名完成 echo 替换完成 pause