我用Dir查看文件列表时发现空内容的文件的大小显示为0,而且“0”的左右都有空白,利用此特点,用两条命令就可做到:
dir xxxx.xxx | find " 0 " >nul
if errorlevel 0 echo xxxx.xxx is empty.
还可以做一个批处理以便判断:
@echo off
if not exist %1 goto none
dir %1 | find " 0 " >nul
if errorlevel 0 echo %1 is empty.
goto end
:none
echo %1 not found!
goto end
:end
将此批处理命名为empty.bat,运行empty xxx.xxx即可看到结果。