批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[文件操作] [分享]查找当前文件夹下全级次的空白子文件夹

  1. @echo off
  2. @rem 保存为ANSI格式
  3. @rem 查找当前文件夹下全级次的空白子文件夹
  4. cd /d "%~dp0"
  5. setlocal enabledelayedexpansion
  6. set "Previous_Folder=%~dp0"
  7. for /f "delims=" %%a in ('dir/b/s/ad^|sort') do (
  8. set "Current_folder=%%a"
  9. call set "dif_str=%%Current_folder:!Previous_Folder!=%%
  10. if "!dif_str!" equ "%%a" call :Process_Empty_Folders
  11. set "Previous_Folder=!Current_folder!"
  12. )
  13. :Process_Empty_Folders
  14. set "Empty_Folder="
  15. for /f "delims=" %%b in ('dir/a/b "!Previous_Folder!"') do (
  16.     set "Empty_Folder=%%b"
  17. )
  18. if "!Empty_Folder!." equ "." (
  19.     echo "!Previous_Folder!" 是空文件夹
  20. )
复制代码

返回列表