批處理文件如下遞歸回聲文件和文件夾,同時加入一些簡單的格式,如縮進顯示遞歸深度,添加「/」前的文件夾名稱,「*」,並跳過名爲「存檔」的文件夾。除了文件和文件夾是隨機排序的,而不是按字母順序排列的,它效果很好。這怎麼可能被改變來按字母順序排序文件和文件夾呢?批處理文件:之前某些文件排序文件夾和文件按字母順序
@echo off
setlocal disableDelayedExpansion
pushd %1
set "tab= "
set "indent="
call :run
exit /b
:run
REM echo the root folder name
for %%F in (.) do echo %%~fF
echo ------------------------------------------------------------------
set "folderBullet=\"
set "fileBullet=*"
:listFolder
setlocal
REM echo the files in the folder
for %%F in (*.txt *.pdf *.doc* *.xls*) do echo %indent%%fileBullet% %%F - %%~tF
REM loop through the folders
for /d %%F in (*) do (
REM skip "Archive" folder
if /i not "%%F"=="Archive" (
REM if in "Issued" folder change the file bullet
if /i "%%F"=="Issued" set "fileBullet= "
echo %indent%%folderBullet% %%F
pushd "%%F"
set "indent=%indent%%tab%"
call :listFolder
REM if leaving "Issued folder change fileBullet
if /i "%%F"=="Issued" set "fileBullet=*"
popd
))
exit /b
謝謝D.完美的作品。 – buttonsrtoys 2013-02-21 11:58:14