for /F %%i in ('dir /b "C:\Program Files\Apache folder\*.*"') do (
echo Folder is NON empty
goto launch_app
)
如何检查文件夹是否为空?
我尝试了上面的命令,但它没有起作用。
for /F %%i in ('dir /b "C:\Program Files\Apache folder\*.*"') do (
echo Folder is NON empty
goto launch_app
)
如何检查文件夹是否为空?
我尝试了上面的命令,但它没有起作用。
试试这个:
for /F %%i in ('dir /b /a "C:\Program Files\Apache folder\*"') do (
echo if you see this the folder is NOT empty
goto launch_app
)
我并不满意给出的答案,因为我尽可能避免使用for循环、goto和临时文件。
检查文件夹是否为空:
dir /b /s /a "C:\Program Files\Apache folder\" | findstr .>nul || (
echo Folder is empty
)
检查文件夹是否为空:
dir /b /s /a "C:\Program Files\Apache folder\" | findstr .>nul && (
echo Folder is NOT empty
)
文件未找到
@for /f "tokens=*" %%a in ('dir /b /a-d "C:\Progra~1\Apache"') do @...
2>NUL
@rem Print a list of file paths
@for /f "tokens=*" %%a in ('dir /b /a-d "%srcPath%" 2^>NUL') do @echo(%srcPath%\%%a
@echo off
cls
echo.
echo.
echo.
echo TEST FOR EMPTY DIRECTORY
echo was tested with "&" without a file
echo.
echo Can use Full or Subfolder path
echo (as below) of where test.bat
echo.
set p=Raw\
echo.
echo Just to show p is set
echo.
echo "p=%p%"
echo.
echo.
echo.
pause
for /F %%i in ('dir /b /a "%p%*"') do (
echo Folder %p% was NOT empty
goto :process
)
echo Folder %p% was empty
:process
echo "BLAH, BLAH, BLAH "
:end
pause
exit
rem Copy past in notepad to try. "Create and use or change the "raw" to your own fancy."
rem Hope this helps. Works great for me and I use it.
rem Have Fun.
rem Note use go to end next line after was empty. Worked great in w10. (this program hmm)
rem IF IT WORKS FOR YOU . GIVE A +. THX!
dir C:\TEST\*.* /a/b/d/od>C:\TEMP\CHECKFOLDER
for /R C:\TEMP\ %%? in (CHECKFOLDER) do (
if "%%~z?"=="0" (
ECHO Folder is empty.
) ELSE (
ECHO Folder is NOT empty
)
)