2017-08-18 56 views
0

我已經開始製作一個批量小程序,它工作得很好,直到我進入IF NOT EXIST,就在那時我的所有問題都開始了,因爲每次進入該語句時批處理文件剛剛崩潰。 下面的代碼:BATCH存在不工作

REM BEGGINING OPTIONS 
@ECHO OFF 
TITLE Organizer 
COLOR 07 
MODE CON COLS=101 LINES=30 
SETLOCAL enableDelayedExpansion 
CLS 

REM WELCOME 
CLS 
COLOR E 
ECHO WELCOME TO ORGANIZER.BAT! THIS PROGRAM IS MADE BY ELDAR BAKERMAN TO ORGANIZE YOUR FILES AND COMPUTER! 
ECHO THIS IS VERSION 1.0! 
ECHO THIS PROJECT STARTED IN 11.08.2017 (DD/MM/YYYY) 
ECHO PRESS ANY KEY TO CONTINUE 
PAUSE>NUL 

REM ORGANIZATION 
:ORGANIZATION 
COLOR 0B 
CLS 
REM CREATE FOLDERNAME VARIABLE 
SET /P FOLDERNAME=WHAT IS THE NAME OF THE FOLDER WHERE THE UNORGANIZED FILES ARE LOCATED IN? 


REM FIND FOLDER 
IF NOT EXIST "D:\Users\Eldar\Desktop\%FOLDERNAME%\NUL" 
(
COLOR 0C 
ECHO ERROR! FOLDER "%FOLDERNAME%" WAS NOT FOUND! 
PAUSE>NUL 
) ELSE (
PAUSE 
) 
PAUSE 
+1

錯誤的括號放置。也許[這](https://stackoverflow.com/a/25073859/2861476)可以幫助 –

回答

0

這裏是你的腳本沒有膨脹:

@ECHO OFF 
SET/P "FOLDERNAME=WHAT IS THE NAME OF THE UNORGANIZED FILES FOLDER? " 
IF NOT EXIST "D:\Users\Eldar\Desktop\%FOLDERNAME%\" (
    ECHO ERROR! FOLDER "%FOLDERNAME%" WAS NOT FOUND! 
) ELSE ECHO "%FOLDERNAME%" WAS FOUND 
PAUSE 

希望你可以看到括號安置工作。