我想做的簡單的事情,但是,我嘗試這樣做沒有成功
@echo off
:start
if not exist "input" mkdir input
if not exist input\* echo Please put a file in "input" folder. && pause && goto start
echo there is a file in "input" folder.
pause
有什么幫助解決嗎?
uj5u.com熱心網友回復:
嘗試列出檔案,看看它是否找到了一些:
dir /b /a-d input\* >nul 2>&1 && echo there is a file || echo folder is empty
/a-d排除子檔案夾(僅列出檔案)
>nul 2>&1丟棄dir(我們不需要它,只要它成功與否)的輸出
&&作為if previous command was successful (files were found) then,
||意味著if it failed (no files found) then
(只是為了解釋為什么if exist不起作用:它找到.和..(當前檔案夾和父檔案夾),技術上是檔案)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/449584.html
上一篇:Mocha:事后如何斷言?
