---------------------------------------------------------本行不複制----------------------1.bat-------------------------------------------------------------------------------
@echo off
setlocal
set LISTFILE=list.htm
echo MAKING LISTFILE … (PLEASE WAIT)
rem 這裡是輸出網頁的頭部,其中^符号表示後一個字元沒有特殊含義,按普通字元處理。
echo ^<head^>^<style type=text/css^>A:link{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION: none} > %LISTFILE%
echo A:visited{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION:none}A:hover{COLOR:#ff0000; >> %LISTFILE%
echo TEXT-DECORATION: underline}BODY{FONT-SIZE:9pt}TABLE{FONT-SIZE:9pt}^</style^>^</head^> >> %LISTFILE%
echo [PROCESSED BY %0]^<br^> >> %LISTFILE%
rem 這裡是最主要的部分,其實就是使用dir指令以最簡單的形式列出目前目錄下(包括子目錄)的所有的檔案
rem 然後使用for來把它轉換為超連結的形式,有興趣可以敲一下這個指令,看看會出現什麼樣的結果:"dir *.* /a:-d/s/b"
for /f "tokens=* delims=" %%i in ('dir *.* /a:-d/s/b') do (
echo ^<a href="%%i" target=_blank^>%%i^</a^>^<br^> >> %LISTFILE%
)
start .\%LISTFILE%
------------------------------------------------------本行不複制,以上内容另存為1.bat,放到任意檔案夾下輕按兩下此bat檔案運作即可------------------------------------
---------------------------------------------------------本行不複制----------------------2.bat-------------------------------------------------------------------------------
::for %a in (*.html) do echo "<a href=%a>%a</a>" >index.html
type head.txt >>index.html
for /d %%a in (*.*) do (
echo ^<a href=%%a/index.html^>%%a^</a^> >>index.html
echo ^<br^> >>index.html
cd %%a
call c:\html.bat
cd ..
for %%b in (*) do (
echo ^<a href=%%b^>%%b^</a^> >>index.html
type end.txt >>index.html
------------------------------------------------------本行不複制,以上内容另存為2.bat,放到任意檔案夾下輕按兩下此bat檔案運作即可------------------------------------