2012-08-25 78 views
0

我想在這部分"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: 
     ) 
    ) 

我讀的論壇上,我發現一提的是,你可以使用& &執行其他命令後直是否存在可我用這裏面的?

+0

看起來好像「轉到EOF」應爲「GOTO:EOF」 - 但是,使腳本在詢問文件夾名稱後立即終止。不知道你想做什麼... –

回答

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,向下滾動到「使用多個命令和條件處理符號」

+0

我已經制定了一個修復,但謝謝 – Kysumi