@echo off & title 批量拷贝目录并创建快捷方式 By 依梦琴瑶
cd /d %~dp0
setlocal enabledelayedexpansion
::设置源文件夹路径
set Src_Dir=ABC
::设置快捷方式存放路径,不存在时会自动创建
set Lnk_Dir=CDE
::设置拷贝后的文件夹前缀名
set Tgt_Dir=XYZ
:InputCount
set /p Count=请输入拷贝次数,回车确认:
if not defined Count (
goto InputError
) else (
Call :CheckInput
)
:NextStart
if %Count% lss 0 (
goto InputError
) else (
if %Count% gtr 99 (
goto InputError
)
)
echo, & call :CreatLnkMakeTool
for %%a in ("%Lnk_Dir%") do (
if not exist "%%~fa" md "%%~fa"
set "Lnk_Dir=%%~fa"
)
set /a Count+=100
for /l %%a in (101,1,%Count%) do (
set "Num=%%~a"
if not exist "%Tgt_Dir% !Num:~1!\terminal.exe" xcopy /s/e "%Src_Dir%" "%Tgt_Dir% !Num:~1!\" >nul
cscript /nologo MakeLnk.vbs "%Lnk_Dir%\!Num:~1!.lnk" "%~dp0%Tgt_Dir% !Num:~1!\terminal.exe" "%~dp0%Tgt_Dir% !Num:~1!" "!Num:~1!.lnk"
)
del /f /q MakeLnk.vbs
echo, & echo 本次处理已完成,请按任意键退出。
pause>nul & exit
:CheckInput
echo %Count%|findstr /c:" " >nul && (
goto InputError
) || (
echo %Count%|findstr ^[0-9][0-9]*$ >nul && (
goto NextStart
) || (
goto InputError
)
)
goto :eof
:InputError
echo, & set "Count="
echo 请务必输入不小于 1 不大于 99 的纯数字,且不能为空或有空格。
ping 127.0.0.1 -n "2">nul
cls & goto InputCount
:CreatLnkMakeTool
(echo Set WshShell = WScript.CreateObject^("WScript.Shell"^)
echo Set oShellLink = WshShell.CreateShortcut^(WScript.Arguments^(0^)^)
echo oShellLink.TargetPath = Chr^(34^) ^& WScript.Arguments^(1^) ^& Chr^(34^)
echo oShellLink.Arguments = "/portable"
echo oShellLink.WorkingDirectory = WScript.Arguments^(2^)
echo oShellLink.Save
echo WScript.Echo "快捷方式 " ^& WScript.Arguments^(3^) ^& " 已创建。")>MakeLnk.vbs
goto :eof
你的奢望,怎么能让你失望呢?所以这样的奢望还是可以成真的。
下个软件