源文件下载

/Files/china-qd/MyTree.zip

@echo off
set shortDirNameTemp=
set rootDirFullName=
set isTime=
if "%~1" EQU "" (call :shortDir "%CD%") else (call :shortDir "%~1")
echo %rootDirFullName% 的目录结构如下:
call :ListADir "%shortDirNameTemp%","%rootDirFullName%",null,true
goto :end

:ListADir ShortDirName DirFullName ForeString isLast
setlocal enabledelayedexpansion
set fileCount=
set muluCount=
set curDirShortName=%~1
set dirFullName=%2
set dirFullNameClear=%~2
set foreStr=%~3
set isLast=%4
set fileFore=
set muluFore=
if "!foreStr!" EQU "null" (set muluFore= )&(set foreStr= ) else (if "!isLast!" EQU "true" ((set muluFore=!foreStr!└─)&(set foreStr=!foreStr!  )) else ((set muluFore=!foreStr!├─)&(set foreStr=!foreStr!│ )))
echo !muluFore!!curDirShortName!

set fileCount=0
set muluCount=0
for /F "tokens=1,2,3,* delims= " %%i in ('dir %dirFullName% /A-D ^2^>nul') do (if "%%j" EQU "个文件" (set fileCount=%%i))
set invalidMulu=0
for /F "tokens=1,2,3,* delims= " %%i in ('dir %dirFullName% /AD ^2^>nul') do ((if "%%j" EQU "个目录" (set muluCount=%%i))&(if "%%l" EQU "." (set /A invalidMulu=!invalidMulu!+1) else (if "%%l" EQU ".." (set /A invalidMulu=!invalidMulu!+1))))
set /A muluCount=!muluCount!-!invalidMulu!

if "!fileCount!" NEQ "0" (
  if "!muluCount!" EQU "0" (set fileFore=!foreStr!  ) else (set fileFore=!foreStr!│ )
  for /F "tokens=1,2,3,* delims= " %%i in ('dir !dirFullName! /A-D ^2^>nul') do (if "%%k" NEQ "" (if "%%i" NEQ "驱动器" (if "%%j" NEQ "个文件" (if "%%j" NEQ "个目录" (
    call :IsATime %%j
    if "!isTime!" EQU "true" (echo !fileFore!%%l %%k)
  )))))
)

set muluCountTemp=!muluCount!
if "!muluCount!" NEQ "0" (

  for /F "tokens=1,2,3,* delims= " %%i in ('dir !dirFullName! /AD ^2^>nul') do (if "%%k" EQU "<DIR>" (if "%%l" NEQ "" (
    if "%%l" NEQ "." (if "%%l" NEQ ".." (
      set /A muluCountTemp=!muluCountTemp!-1
      if "!muluCountTemp!" EQU "0" (set isLastTemp=true) else (set isLastTemp=false)
      set dirFullNameTemp=!dirFullNameClear!\%%l
      call :ListADir "%%l","!dirFullNameTemp!","!foreStr!",!isLastTemp!
      if "!muluCountTemp!" EQU "0" (goto :out01)
    ))
  )))
 
)

:out01
endlocal
goto :end


:shortDir
set rootDirFullName=%~1
set shortDirPara1=%~1
set shortDir01=%shortDirPara1:~-1%
if "%shortDir01%" EQU "\" (set rootDirFullName="%shortDirPara1:~0,-1%")
call :stDir2 "%rootDirFullName%"
goto :end

:stDir2
set shortDirNameTemp=%~nx1
if not defined shortDirNameTemp (set shortDirNameTemp="%~1")
goto :end

:IsATime timeStr
set timeStr=%1
for /F "tokens=1,2 delims=:" %%i in ("%timeStr%") do (if "%%j" EQU "" (set isTime=false) else (set isTime=true))
goto :end

:end