起因是这样的,拿到一个网站的下载包,回来一看是残缺不全的。要核对后才知道差哪些文件,苦差事!而这些文件名是由序列数构成的,像这样:www.xxx.com/xxx/file1.html、www.xxx.com/xxx/file2.html……www.xxx.com/xxx/file389.html
鼓捣半天,弄了些批处理解决,思路是先生成序列数,再用exist判断。
开始之前为稳妥起见,把.html改为了.htm
a.bat
b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
;实际上第一个批处理文件也是用批处理生成的。
b.bat
@echo off
for %%a in (1,2,3,4,5,6,7,8,9) do call c node%%a.htm
:redo
if "%1" == "" goto end
for %%a in (0,1,2,3,4,5,6,7,8,9) do call c node%1%%a.htm
if errorlevel 2 goto end
shift
goto redo
:end
c.bat
@echo off
if not exist %1 echo %1 >> urls.lst
echo on
最后得到的urls.lst就是需要的文件。嗬嗬,再批处理下载去~<img src="images/smilies/face-raspberry.png" align="absmiddle" border="0">
Last edited by bush on 2005-11-26 at 00:13 ]
The cause is like this. Got a download package of a website, came back and saw it was incomplete. Had to check to know which files were missing, a thankless task! And these file names are composed of sequence numbers, like this: www.xxx.com/xxx/file1.html、www.xxx.com/xxx/file2.html……www.xxx.com/xxx/file389.html.
Fiddled around for a long time and came up with some batch processing solutions. The idea was to generate sequence numbers first and then use exist to judge.
Before starting, for safety, changed.html to.htm
a.bat
b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
;Actually the first batch processing file was also generated with batch processing.
b.bat
@echo off
for %%a in (1,2,3,4,5,6,7,8,9) do call c node%%a.htm
:redo
if "%1" == "" goto end
for %%a in (0,1,2,3,4,5,6,7,8,9) do call c node%1%%a.htm
if errorlevel 2 goto end
shift
goto redo
:end
c.bat
@echo off
if not exist %1 echo %1 >> urls.lst
echo on
The finally obtained urls.lst is the needed file. Hehe, then batch process to download ~ :P
Last edited by bush on 2005-11-26 at 00:13 ]