Windows环境的Jenkins编译,上传到FTP,但是Windows不区分大小写,FTP区分,导致经常找不到文件,用下面批处理把文件夹和文件名改回小写。
把扩展名为exe修改为小写
rem 修改exe为小写文件名 setlocal setlocal ENABLEDELAYEDEXPANSION set path=".\" set suf="*.exe" rem %path% #使用变量 for /f "delims=" %%i in ('dir /b/s/a-d %path%\%suf%') do ( set h="%%~ni" for %%j in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set h="!h:%%j=%%j!" ren "%%i" "!h!"%suf% ) endlocal
把WORKSPACE工作路径中所有文件和文件夹名修改为小写
cd %WORKSPACE% for /f "delims=" %%a in ('dir /b /l') do ren "%%a" "%%a" for /d /r %%b in (*) do ( pushd "%%b" for /f "delims=" %%c in ('dir /b /l') do ren "%%c" "%%c" popd )
把WORKSPACE工作路径中所有文件夹名修改为小写,把扩展名为exe和pdb的文件名修改为小写
setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir /b/l/ad "%WORKSPACE%"') do (ren "%WORKSPACE%\%%i" "%%i") for /f "delims=" %%i in ('dir /b/l/a-d "%WORKSPACE%\%ProjName%\%BuildFlag%\*.exe"') do (ren "%WORKSPACE%\%ProjName%\%BuildFlag%\%%i" "%%i") for /f "delims=" %%i in ('dir /b/l/a-d "%WORKSPACE%\%ProjName%\%BuildFlag%\*.pdb"') do (ren "%WORKSPACE%\%ProjName%\%BuildFlag%\%%i" "%%i") endlocal
转载请注明:果果.IT » 自动运维:批处理修改Windows文件夹文件名为小写