China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 14:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Resolved] Help: Use a batch file to make webpage pagination links View 2,850 Replies 21
Floor 16 Posted 2009-02-05 10:07 ·  中国 上海 华为云
初级用户
Credits 49
Posts 37
Joined 2007-05-08 09:38
19-year member
UID 87820
Gender Male
Status Offline
A question: if I want to change, for example,

D First page A B2 C3 D4 E5 F6 4/19 Last page S
E First page A C3 D4 E5 F6 G7 5/19 Last page S
F First page A D4 E5 F6 G7 H8 6/19 Last page S

into:

D First page A B2 C3 Current page:D4 E5 F6 4/19 Last page S
E First page A C3 D4 Current page:E5 F6 G7 5/19 Last page S
F First page A D4 E5 Current page:F6 G7 H8 6/19 Last page S

Can it be changed into this style? That is, add 'Current page' before the current page. I once tried to modify your code above, but found it impossible unless the algorithm is changed.
Floor 17 Posted 2009-02-05 18:59 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Originally posted by ganjie at 2009-2-4 03:17 AM:
Thanks to netbenton for specially uploading the file. I tested it carefully myself, and after dragging the directory onto it, the batch window still disappears immediately, and none of the htm files have any content changes. There really is no response at all! Could you ...

Hehe
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 18 Posted 2009-02-05 19:43 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
Find these three places:
1. set xn=0
2. set/a ms+=1,mb+=1
3. if not defined fn%2 (set "pr=<td scope="col"><a href="!fn%1!">%1</a></td>"&!echo !pr!&set/a xn+=1)

Change them to:
1. set xn=0&set "dqym%%a=Current page:"
2. set/a ms+=1,mb+=1&set dqym%%a=
3. if not defined fn%2 (set "pr=<td scope="col"><a href="!fn%1!">!dqym%1!%1</a></td>"&!echo !pr!&set/a xn+=1)

[ Last edited by netbenton on 2009-2-5 at 19:44 ]
精简
=> 个人网志
Floor 19 Posted 2009-02-06 08:19 ·  中国 上海 华为云
初级用户
Credits 49
Posts 37
Joined 2007-05-08 09:38
19-year member
UID 87820
Gender Male
Status Offline
So that's all it takes to change it. I originally thought that after adding the current link, the algorithm would definitely have to be modified. This way I can modify the current page item myself.
For example, the pagination links for the C file are as follows:
<table widtd="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td scope="col"><a href="A.htm">First page</a></td>
<td scope="col"><a href="B.htm">Previous page</a></td>
<td scope="col"><a href="A.htm">1</a></td>
<td scope="col"><a href="B.htm">2</a></td>
<td scope="col"><a href="C.htm">3</a></td>
<td scope="col"><a href="D.htm">4</a></td>
<td scope="col"><a href="E.htm">5</a></td>
<td scope="col"><a href="F.htm">Next page</a></td>
<td scope="col">3/19</td>
<td scope="col"><a href="S.htm">Last page</a></td>
</tr>
</table>
This way I can change the current page part <td scope="col"><a href="C.htm">3</a></td>
to <strong>3</strong> for CSS needs. How can I change it like this?
Floor 20 Posted 2009-02-06 09:04 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
I really wish the OP could explain the problem clearly all at once...

Just change the third line to this, and it'll work.
if not defined fn%2 (
if defined dqym%1 (set "pr=<td scope="col"><strong>%1</strong></td>") else (set "pr=<td scope="col"><a href="!fn%1!">%1</a></td>")
echo !pr!&set/a xn+=1
)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
HAT +2 2009-02-06 13:51
精简
=> 个人网志
Floor 21 Posted 2009-02-06 09:21 ·  中国 上海 华为云
初级用户
Credits 49
Posts 37
Joined 2007-05-08 09:38
19-year member
UID 87820
Gender Male
Status Offline
Sorry, my apologies! I really should have wrapped this up long ago, but for better appearance I started using CSS styles, so... enough talk, I tested it and it worked. Thanks, many thanks!
Floor 22 Posted 2009-10-09 08:08 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
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
RaterScoreTime
ganjie +2 2009-10-09 12:20
精简
=> 个人网志
Forum Jump: