我有以下脚本将删除BlackBerry上的文件。
但是,每次我运行它时,它都会提示我将光盘插入驱动器G.是否可以重做它以便不这样做?
@ECHO OFF
CLS
IF EXIST F:\home\user\videos\Star.avi (
ECHO "File Exists"
DEL F:\home\user\videos\Star.avi
) ELSE (
IF exist E:\home\user\videos\Star.avi (
ECHO "File Exists"
DEL E:\home\user\videos\Star.avi
) ELSE (
IF EXIST G:\home\user\videos\Star.avi (
ECHO "File Exists"
DEL G:\home\user\videos\Star.avi
) ELSE (
ECHO "File Doesn't Exist"
)
)
)
答案 0 :(得分:2)
@ECHO OFF
CLS
SET DRIVE=
FOR %%D IN (E: F: G:) DO (
IF EXIST %%D\home\user\videos\Star.avi (
SET DRIVE=%%D
GOTO EXIT
)
)
:EXIT
IF DEFINED DRIVE (
ECHO "File Exists"
DEL %DRIVE%\home\user\videos\Star.avi
) ELSE (
ECHO "File Doesn't Exist"
)
答案 1 :(得分:1)
你的paranthese对可能有些不对劲。为什么不简化:
IF EXIST E:\home\user\videos\Star.avi (del E:\home\user\videos\Star.avi & goto exit)
IF EXIST F:\home\user\videos\Star.avi (del f:\home\user\videos\Star.avi & goto exit)
IF EXIST G:\home\user\videos\Star.avi (del g:\home\user\videos\Star.avi & goto exit)
:exit