tree命令查找H盘txt文件,并排除不含txt的文件夹:- @echo off&setlocal enabledelayedexpansion
- tree h: /f|findstr /rc:"├" /c:"└" /c:"\.txt$">treelist.txt
- cd.>空.tmp
- set n=1
- (for /f "tokens=2 delims=:" %%a in ('fc /n treelist.txt 空.tmp^|find ": "^|sort /r') do (
- set tmp=%%a
- if !tmp:~-4! neq .txt (set /a n+=1) else set n=0
- if !n! leq 1 echo %%a
- ))>tmp.txt
- (for /f "tokens=2 delims=:" %%a in ('fc /n tmp.txt 空.tmp^|find ": "^|sort /r') do echo %%a)>treelist.txt
- pause
复制代码 效率很低,其实这样大肆修改还不如dir后自己diy目录树 |