bat批量拷贝文件并重命名

@echo off
echo =====================================
@echo.
echo 使用说明:输入测试sql所在的目录,测试sql文件d100开头,
echo 会拷贝为bili,ios,uo,yyb开头的文件,并保存在上一层目录
@echo.                      
echo =====================================

:loop
set/p tmpSQLPATH=请输入测试sql的目录:
set SQLPATH=%tmpSQLPATH%
if %SQLPATH%=='' goto loop
goto start-copy
@echo.
goto loop

:start-copy
cd %SQLPATH%
cd ..
set dst=%cd%
echo 开始复制到 %dst% 
for /f "delims=" %%i in ('dir /b/a "%SQLPATH%"') do (
	call :doit "%%i"
)
goto exit

:doit
set sourceFileName=%1
copy %SQLPATH%\%sourceFileName% %dst%\%sourceFileName:d100=bili%
copy %SQLPATH%\%sourceFileName% %dst%\%sourceFileName:d100=ios%
copy %SQLPATH%\%sourceFileName% %dst%\%sourceFileName:d100=uo%
copy %SQLPATH%\%sourceFileName% %dst%\%sourceFileName:d100=yyb%
goto:eof

:exit
pause

你可能感兴趣的:(脚本)