本帖最后由 CrLf 于 2015-2-27 22:33 编辑
以7楼为例是这样- @echo off&setlocal enabledelayedexpansion
- set n=0
- for /f "delims=" %%a in ('dir /b article???.htm') do (
- set /a n+=1
- set "htm[!n!]=%%a"
- )
-
- for /l %%a in (1 1 !n!) do (
- set /a last=%%a-1,next=%%a+1
- for /f "tokens=1,2" %%b in ("!last! !next!") do set last=!htm[%%b]!&set next=!htm[%%c]!
-
- echo ^<div align=right^>
- if %%a gtr 1 echo ^<a href="!last!"^>上一页^</a^>
- echo ^<a href="index.htm"^>目录页^</a^>
- if %%a lss !n! echo ^<a href="!next!"^>下一页^</a^>
- echo ^</div^>
- )>>!htm[%%a]!
- pause
复制代码 以顶楼为例则是- @echo off&setlocal enabledelayedexpansion
-
- for /f "delims=" %%a in ('dir /b *.html') do (
- set /a n=%%~na,last=n-1,next=n+1
-
- echo ^<div align=right^>
- if exist !last!.html echo ^<a href="!last!.html"^>上一页^</a^>
- echo ^<a href="index.html"^>目录页^</a^>
- if exist !next!.html echo ^<a href="!next!.html"^>下一页^</a^>
- echo ^</div^>
- )>>%%a
- pause
复制代码
|