Board logo

标题: [文件操作] [分享]查找当前文件夹下全级次的空白子文件夹 [打印本页]

作者: hfxiang    时间: 2022-9-26 10:53     标题: [分享]查找当前文件夹下全级次的空白子文件夹

  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. )
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2