我有一段时间以前制作的这段代码。如果文件夹名称存在,则提示用户输入其他名称是一个简单的检查。由于某种原因,它不起作用。如果该文件夹存在,应 Goto AskForFolderName
。我想不明白。
@echo off
@setlocal enableextensions enabledelayedexpansion
mode 90,10
color a
::Stage 3 - Check Folder
:AskForFolderName
set /p NewFolder=What is the name of the iteam being sold?
If ["%NewFolder%"]==[] Goto AskForFolderName
If Exist "%NewFolder%" (
Echo Folder already exists
Echo.
Goto AskForFolderName
)
Mkdir "003 - Images Ready\%NewFolder%"
Move "002 - Process Images\"*.* "003 - Images Ready\%NewFolder%"
ping 127.0.0.1 -n 20 > nul
exit
答案 0 :(得分:1)
试试这个:
@echo off & setlocal enableextensions enabledelayedexpansion
mode 90,10
color a
::Stage 3 - Check Folder
:AskForFolderName
set /p "NewFolder=What is the name of the iteam being sold? "
If "%NewFolder%"=="" Goto :AskForFolderName
If Exist "003 - Images Ready\%NewFolder%\" (
Echo Folder already exists
Echo.
Goto AskForFolderName
)
Mkdir "003 - Images Ready\%NewFolder%"
Move "002 - Process Images\*.*" "003 - Images Ready\%NewFolder%"
Timeout /NoBreak /T 20 > nul
exit