源码里面的SET /P如果不小心按到回车键会复制全部,有什么方法可以让其只有回车键没有选择时,返回到选择界面而不复制全部吗?复制代码
- @echo off
- color 02
- :主界面
- cls
- echo.
- echo --------------------------------------
- echo 1、目录1
- echo --------------------------------------
- echo 2、目录2
- echo --------------------------------------
- echo 3、目录3
- echo --------------------------------------
- echo.
- choice /c 123 /n /m "请选择对应功能"
- if %errorlevel% EQU 1 echo 目录1&goto :目录1
- if %errorlevel% EQU 2 echo 目录2&goto :目录2
- if %errorlevel% EQU 3 echo 目录3&goto :目录3
- rem -------------------------------------------------------------------------------------------------------------
- rem -------------------------------------------------------------------------------------------------------------
- :目录1
- cls
- setlocal enabledelayedexpansion
- set 序号=1
- for /f "delims=" %%i in ('dir /b "NAS网盘路径"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- echo.
- set /p 选择=-输入序号:
- robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PURGE /IS
- cls
- set 序号=1
- for /f "delims=" %%i in ('dir /b "C:\123"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- start /wait "" "C:\123\!文件[%选择%]!"
- rd /s /q "C:\123"
- goto :主界面
- exit
- rem -------------------------------------------------------------------------------------------------------------
- rem -------------------------------------------------------------------------------------------------------------
- :目录2
- cls
- setlocal enabledelayedexpansion
- set 序号=1
- for /f "delims=" %%i in ('dir /b "NAS网盘路径"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- echo.
- set /p 选择=-输入序号:
- robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PURGE /IS
- cls
- set 序号=1
- for /f "delims=" %%i in ('dir /b "C:\123"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- start /wait "" "C:\123\!文件[%选择%]!"
- rd /s /q "C:\123"
- goto :主界面
- exit
- rem -------------------------------------------------------------------------------------------------------------
- rem -------------------------------------------------------------------------------------------------------------
- :目录3
- cls
- setlocal enabledelayedexpansion
- set 序号=1
- for /f "delims=" %%i in ('dir /b "NAS网盘路径"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- echo.
- set /p 选择=-输入序号:
- robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PURGE /IS
- cls
- set 序号=1
- for /f "delims=" %%i in ('dir /b "C:\123"') do (
- set 文件[!序号!]=%%~nxi
- echo -----------------------------
- echo ^>^>^>(!序号!)%%i
- set /a 序号+=1)
- echo -----------------------------
- start /wait "" "C:\123\!文件[%选择%]!"
- rd /s /q "C:\123"
- goto :主界面
- exit
源码里面的SET /P如果不小心按到回车键会复制全部,有什么方法可以让其只有回车键没有选择时,返回到选择界面而不复制全部吗?复制代码
- set /p 选择=-输入序号:
- robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PURGE /IS
set /p 选择=-输入序号:
if not "%选择%"=="" (robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PUR ...
Fit 发表于 2021-12-13 19:56
set /p 选择=-输入序号:
if not "%选择%"=="" (robocopy "NAS网盘路径" "C:\123" "!文件[%选择%]!" /PUR ...
Fit 发表于 2021-12-13 19:56
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |