我想在此部分"if exist "%%d:\%folder%\" (echo Device was found on %%d:)"
为这段代码添加另一条指令,所以如果找到该文件夹,那么set folderfound="%%d:\%folder%\"
是否可以做类似的事情?
这是完整的代码,以显示我想要做什么
:autodetect1
set /p "folder=Folders Name that the photo's are in: "
setlocal
set folder=%1
if "%folder%" == "" call :autodetect1
cls
for %%d in (d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%d:\%folder%\" (
echo Device was found on %%d: and set folderfound=%%d:\%folder%\
) else (
echo Device was not found on %%d:
)
)
我正在论坛上阅读,我发现提到你可以使用&&我可以在if if中使用它之后直接执行另一个命令吗?
答案 0 :(得分:0)
使用“&&”您在以下代码中使用“和”的位置似乎设置了folderfound变量:
@echo off
:autodetect1
set /p "folder=Folders Name that the photo's are in: "
rem goto :eof
rem setlocal
rem set folder=%1
rem if "%folder%" == "" call :autodetect1
rem cls
for %%d in (d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%d:\%folder%\" (
echo Device was found on %%d: && set folderfound=%%d:\%folder%\
) else (
echo Device was not found on %%d:
)
)
我已经注释掉了一些我不理解的内容。
您需要了解此处发生的情况,转到http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx并向下滚动到“使用多个命令和条件处理符号”