The OP added a new question:
Change the mutually linked files from 5 to n:
@echo off
::If %1 specifies the directory to process, then process that directory; if the given directory does not exist or is not specified, then process the current directory.
if '%1'=='#benton#' goto :bengin
if not '%1==' pushd %1
for /f "tokens=* delims=" %%a in ('dir /ad /s /b^&cd') do (
pushd %%a
call %0 #benton#
popd
)
if not '%test%=='t echo No *.htm files found under directory "%cd%"
if not '%1==' popd
pause
goto :eof
:bengin
if not exist *.htm goto :eof
set test=t&echo.
if exist chmchm.abc echo Directory "%cd%" already has a chm, skipping this time,&echo.If you want to add it again, please delete chmchm.abc in that directory and try again.&goto :eof
echo Directory %cd%
echo.>chmchm.abc
setlocal enabledelayedexpansion
set "num=7" define the number of items here, any number of items is fine
set "fg=<td scope="col">.</td>" define the separator here
set/a n=0
for %%a in (*.htm) do (
set /a n+=1
set fn!n!=%%a
)
set "z1=<table widtd="500" border="0" align="center" cellpadding="0" cellspacing="0">"
set "z2=<tr>"
set "z3=<td scope="col"><a href="!fn1!">First page</a></td>"
set "z8=<td scope="col"><a href="!fn%n%!">Last page</a></td>"
set "z9=</tr>"
set "z10=</table>"
if !n! gtr 1 goto :noly
(echo !z1!&echo !z2!
set "z5=<td scope="col"><a href="!fn1!">1</a></td>"
set "z7=<td scope="col">1/1</td>"
echo !z5!&echo !z7!&echo !z9!&echo !z10!)>>!fn1!
goto :eof
:noly more than one file
for /l %%a in (1,1,!n!) do (
echo Writing file: !fn%%a!
set "z7=<td scope="col">%%a/!n!</td>"
set/a pup=%%a-1,pdo=%%a+1
(echo;!z1!&echo;!z2!&echo;!z3!
call :save %%a
echo;!z7!&echo;!z8!&echo;!z9!&echo;!z10!)>>!fn%%a!
)
endlocal
echo Writing complete
pause
goto :eof
:save
if defined fn%pup% set "z4=<td scope="col"><a href="!fn%pup%!">Previous page</a></td>"&echo !z4!
echo !fg!
set/a sn=0,ms=%1-num,mb=%1+num-1,nun=num/2+1,mmm=0
for /l %%a in (!ms!,1,!mb!) do (
set/a xn=%%a+num,mmm+=1
set yy=
if not defined fn!xn! (set yy=1) else (
if !mmm! gtr !nun! set yy=1
)
if defined fn%%a (
if defined yy (
set "pr=<td scope="col"><a href="!fn%%a!">%%a</a></td>!fg!"
if %%a equ %1 set "pr=<td >%%a</td>!fg!"
rem This line removes the link from the current item. If you don't need that, you can delete it.
echo !pr!
set/a sn+=1
)
)
if !sn! equ !num! goto :ok
)
:ok
if defined fn%pdo% set "z6=<td scope="col"><a href="!fn%pdo%!">Next page</a></td>"&echo !z6!
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
| ganjie |
+2 |
2009-10-09 12:20 |