批量判断文件夹是否有文件
Determine if folder have a file or not in batch
我想做的事情很简单,但是,
我尝试这样做但没有成功
@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
任何修复帮助?
尝试列出文件并查看是否找到了一些:
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
不起作用:它找到 .
和 ..
(当前文件夹和父文件夹),技术上是文件)
我想做的事情很简单,但是, 我尝试这样做但没有成功
@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
任何修复帮助?
尝试列出文件并查看是否找到了一些:
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
不起作用:它找到 .
和 ..
(当前文件夹和父文件夹),技术上是文件)