文章摘要
本文介绍了用Bash脚本搜索空目录的完整方法。代码通过`dir /AD /ON /B`命令查找所有空目录,并将结果保存到`result.txt`文件中。脚本还使用了`SetLocal`、`Color`等自定义设置,并通过`del tempp`清理临时文件。文章还提供了作者的网站链接,方便读者进一步了解或使用该脚本。
::Search for empty dirs.
::by lvfeng, Mar 11,2009
::Search for empty dirs.
::by lvfeng, Mar 11,2009
@echo off
setlocal enabledelayedexpansion
color 1E
echo 本程序搜索空目录
echo.
echo by www.lfhacks.com
echo.
echo 按任意键开始…
pause >NUL
dir /AD /ON /B >tempp
if exist result.txt del result.txt
echo.
echo 搜索到的空目录有:
for /f “tokens=*” %%i in (tempp) do (
dir “%%i”|find ” 0 File(s)” > NUL
set nofile=!errorlevel!
dir “%%i”| find ” 2 Dir(s)” > NUL
if !errorlevel!==0 if !nofile!==0 (echo %%i
echo %%i >> result.txt
)
)
del tempp
echo.
echo 搜索结果已导出到result.txt
echo.
echo www.lfhacks.com
pause >NUL
exit
© 版权声明
文章版权归作者所有,未经允许请勿转载。



