|
w1314ich
中级用户
  
积分 234
发帖 119
注册 2007-4-22
状态 离线
|
『楼 主』:
[已结]批处理筛选保留文本指定内容
使用 LLM 解释/回答一下
有一个网页首页文件,改成TXT打开后,里面有很多内容,如下:
===============================================
<html>
<head>
<title>XXXXXXXXXXX</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css">
</head>
<body background=images/bg.gif leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<TABLE WIDTH=775 BORDER=0 CELLPADDING=0 CELLSPACING=0 align=center>
<TR>
<TD ROWSPAN=2>
<IMG SRC="images/title_01.gif" WIDTH=644 HEIGHT=81 ALT=""></TD>
<TD>
<a href="gywmen.asp"><IMG SRC="images/title_02.gif" WIDTH=131 HEIGHT=17 border=0></a></TD>
</TR>
<TR>
<TD>
<IMG SRC="images/title_03.gif" WIDTH=131 HEIGHT=64 ALT=""></TD>
</TR>
</TABLE>
<TABLE WIDTH=775 BORDER=0 CELLPADDING=0 CELLSPACING=0 align=center bgcolor=#ffffff>
<TR>
<TD>
<a href="index.asp"><IMG SRC="images/botton_up_01.gif" WIDTH=37 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_01.gif'" onmouseout="JavaScript:this.src='images/botton_up_01.gif'" onclick="JavaScript:this.src='images/botton_over_01.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="xhjs1.asp"><IMG SRC="images/botton_up_02.gif" WIDTH=70 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_02.gif'" onmouseout="JavaScript:this.src='images/botton_up_02.gif'" onclick="JavaScript:this.src='images/botton_over_02.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="hyzj1.asp"><IMG SRC="images/botton_up_03.gif" WIDTH=70 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_03.gif'" onmouseout="JavaScript:this.src='images/botton_up_03.gif'" onclick="JavaScript:this.src='images/botton_over_03.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="xhxx1.asp"><IMG SRC="images/botton_up_04.gif" WIDTH=71 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_04.gif'" onmouseout="JavaScript:this.src='images/botton_up_04.gif'" onclick="JavaScript:this.src='images/botton_over_04.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="hydt1.asp"><IMG SRC="images/botton_up_05.gif" WIDTH=71 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_05.gif'" onmouseout="JavaScript:this.src='images/botton_up_05.gif'" onclick="JavaScript:this.src='images/botton_over_05.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="jlhz1.asp"><IMG SRC="images/botton_up_06.gif" WIDTH=70 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_06.gif'" onmouseout="JavaScript:this.src='images/botton_up_06.gif'" onclick="JavaScript:this.src='images/botton_over_06.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="pxtd1.asp"><IMG SRC="images/botton_up_07.gif" WIDTH=71 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_07.gif'" onmouseout="JavaScript:this.src='images/botton_up_07.gif'" onclick="JavaScript:this.src='images/botton_over_07.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="zcfg1.asp"><IMG SRC="images/botton_up_08.gif" WIDTH=68 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_08.gif'" onmouseout="JavaScript:this.src='images/botton_up_08.gif'" onclick="JavaScript:this.src='images/botton_over_08.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="wscy.asp"><IMG SRC="images/botton_up_09.gif" WIDTH=72 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_09.gif'" onmouseout="JavaScript:this.src='images/botton_up_09.gif'" onclick="JavaScript:this.src='images/botton_over_09.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="wlzwhjj.asp"><IMG SRC="images/botton_up_10.gif" WIDTH=70 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_10.gif'" onmouseout="JavaScript:this.src='images/botton_up_10.gif'" onclick="JavaScript:this.src='images/botton_over_10.gif'" style="cursor:hand"></a></TD>
<TD>
<a href="http://www.ec315.cn/onlinets.asp" target=_blank><IMG SRC="images/botton_up_11.gif" WIDTH=68 HEIGHT=25 border=0 onmouseover="JavaScript:this.src='images/botton_over_11.gif'" onmouseout="JavaScript:this.src='images/botton_up_11.gif'" onclick="JavaScript:this.src='images/botton_over_11.gif'" style="cursor:hand"></a></TD>
</TR>
</TABLE>
<table width=775 border=0 cellpadding=0 cellspacing=0 align=center valign=top bgcolor=#ffffff>
<tr>
<td height=100% valign=top>
<table border=0 cellspacing=0 cellpadding=0 width=178 height=100% align=center valign=top bgcolor=#f2f2f2>
<script language="javascript">
function submitform()
{
frm_login.submit();
}
</script>
<script language="javascript">
function cleartext() {
if (document.Form1.text1.value=='输入关键字')
document.Form1.text1.value='';
}
</script>
<tr>
<td valign=top>
<form name="frm_login" method="post" action="chk_login.asp">
<table border=0 cellspacing=0 cellpadding=0 width=178 height=103 align=center valign=top>
<tr>
<td valign=top height=22><img src="images/login_01.gif"></td>
</tr>
<tr>
<td valign=top height=80 bgcolor=#F2F2F2 align=center>
<table border=0 cellspacing=0 cellpadding=0 width=150 height=60 align=center valign=top>
<tr>
<td class=f2>用户名:</td>
<td><INPUT type="text" name="username" class=input1></td>
</tr>
<tr>
<td class=f2>密码:</td>
<td><INPUT type="password" id="password" name="password" class=input1></td>
</tr>
<tr><td height=6 colspan=2></td></tr>
<tr>
<td><input type=image onClick="submitform()" src=images/login_02.gif border=0 id=image1 name=image1></td>
<td><a href="wsdj.asp"><img src="images/login_03.gif" border=0></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=top height=1 bgcolor=#C9C9C9></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td height=8></td>
</tr>
<tr>
<td>
<table border=0 cellspacing=0 cellpadding=1 width=170 height=66 align=center valign=top bgcolor=#CBCBCB>
<tr>
<td>
<table border=0 cellspacing=0 cellpadding=0 width=168 height=64 align=center valign=top bgcolor=#ffffff>
<tr>
<td valign=top><img src="images/search_01.gif"></td>
</tr>
<form action=search.asp method=post ID="Form1" name=Form1>
<tr>
<td valign=top align=center>
<INPUT onfocus="cleartext();" type="text" id=text1 name=text1 value=输入关键字 class=input2>
<input type=image src=images/search_02.gif border=0 id=image1 name=image1>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td align=center><a href=mailto:seca@sh-ec.org.cn><img src="images/mail.gif" border=0></a></td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td align=center valign=top><a href="qikan.asp"><img src="images/publication.gif" border=0></a></td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td align=center valign=top>
<table border=0 cellspacing=0 cellpadding=1 width=170 height=250 align=center valign=top bgcolor=#CBCBCB>
<tr>
<td>
<table border=0 cellspacing=0 cellpadding=0 width=168 height=248 align=center valign=top bgcolor=#ffffff>
<tr>
<td valign=top><img src="images/online_research_01.gif"></td>
</tr>
<tr>
<td valign=top align=center class=f2><script src="admin/vote/vote_js.asp"></script>
</td>
</tr>
<tr>
<td valign=top align=center height=8></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td align=center valign=top><a href="zddh.asp"><img src="images/webnavigation_logo.gif" border=0></a></td>
</tr>
<tr>
<td height=8 align=center valign=top></td>
</tr>
<tr>
<td align=center valign=top><a href="lxwm.asp"><img src="images/contactUS.gif" border=0></a></td>
</tr>
<tr>
<td height=100% align=center valign=top></td>
</tr>
</table>
</td>
<td width=1 bgcolor=#c9c9c9 height=100%></td>
<td>
<table width=596 border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td height=103><a href="http://www.ec315.cn"><img src="images/ec315.gif" border=0></a></td>
</tr>
<tr>
<td width=596 height=25 background="images/bg_01.gif"></td>
</tr>
<tr>
<td>
<table width=596 border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td height=80% width=412>
<table width=412 border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td>
<table width=394 border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td>
<img src="images/center_01.gif" width=144 height=32 alt=""></td>
<td>
<img src="images/center_02.gif" width=24 height=32 alt=""></td>
<td colspan=2>
<a href="xhxx1.asp?id=42"><img src="images/center_03.gif" width=226 height=32 border=0></a></td>
</tr>
<tr>
<td width=144 height=200 bgcolor=#c0c2ca align=center class=f1>
<DIV><A href="http://210.13.118.19/gather/dataGather/index.jsp"></A></DIV><A href="http://210.13.118.19/gather/dataGather/index.jsp"><IMG height=99 alt=上海市电子商务统计网上直报系统登录 src="http://www.sh-ec.org.cn/upload/tongji_logo9.JPG" width=142 align=center border=0></A>
<P align=left><FONT size=2>上海市电子商务统计网上直报系统登录</FONT></P></FONT>,
</td>
<td width=24 height=200 background="images/center_05.gif"></td>
<td width=219 height=200>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td class=f_time>·<a href="news.asp?id=842" class=af0 target="_blank">上海电子商务行业协会推动网上诚信建设</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=835" class=af0 target="_blank">上海市电子商务行业协会第一届第六次理事会会议召开</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=832" class=af0 target="_blank">传统大厂变"网上大户"上海B2B电子交易破2000亿</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=831" class=af0 target="_blank">统计快报显示,2007全年上海市电子商务交易额达2407.3亿</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=830" class=af0 target="_blank">2007年上海电子商务交易额突破2400亿</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=829" class=af0 target="_blank">“2008虹口区网上创业技能大赛”成功举办</a></td>
</tr>
<tr>
<td class=f_time>·<a href="news.asp?id=828" class=af0 target="_blank">“展望08”暨上海市电子商务行业协会春节茶话会于近日成功举办</a></td>
</tr>
</table>
</td>
<td width=7 height=200 background="images/center_07.gif"></td>
</tr>
<tr>
<td>
<img src="images/center_08.gif" width=144 height=12 alt=""></td>
<td>
<img src="images/center_09.gif" width=24 height=12 alt=""></td>
<td>
<img src="images/center_010.gif" width=219 height=12 alt=""></td>
<td>
<img src="images/center_011.gif" width=7 height=12 alt=""></td>
</tr>
</table>
</td>
</tr>
<tr><td height=15></td></tr>
<tr>
<td>
<table width=394 border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td>
<table width=184 border=0 cellpadding=0 cellspacing=0>
<tr>
<td>
<a href="wscy.asp"><img src="images/center_1_01.gif" width=184 height=59 alt="" border="0"></a></td>
</tr>
<tr>
<td background="images/center_1_02.gif" width=184 height=84>
<TABLE cellSpacing=0 cellPadding=0 width=160 align=center border=0>
<TBODY>
<TR>
<TD class=f_time><A href="wscy_news.asp?id=66"> · 网上卖家诚信承诺登记</A><BR><A href="wscy_news.asp?id=56"> · 创业快讯</A><BR><A href="wscy_news.asp?id=58"> · 创业程序</A><BR><A href="wscy_news.asp?id=57"> · 创业成功案例1 </A></TD></TR></TBODY></TABLE>
</td>
</tr>
<tr>
<td>
<img src="images/center_1_03.gif" width=184 height=14 alt=""></td>
</tr>
</table>
</td>
<td width=6></td>
<td>
<table width=184 border=0 cellpadding=0 cellspacing=0>
<tr>
<td>
<a href="jlhz1.asp"><img src="images/center_2_01.gif" width=184 height=59 alt="" border="0"></a></td>
</tr>
<tr>
<td background="images/center_1_02.gif" width=184 height=84>
<TABLE cellSpacing=0 cellPadding=0 width=160 align=center border=0>
<TBODY>
<TR>
<TD class=f_time>
<P>
<TABLE cellSpacing=0 cellPadding=0 width=160 align=center border=0>
<TBODY>
<TR>
<TD class=f_time><A href="jlhz1.asp?id=51">· 会展论坛动态</A><BR><A href="jlhz1.asp?id=52">· 历次展会信息</A><BR><A href="jlhz1.asp?id=53">· 历次论坛资料</A></TD></TR></TBODY></TABLE></P></TD></TR></TBODY></TABLE>
</td>
</tr>
<tr>
<td>
<img src="images/center_1_03.gif" width=184 height=14 alt=""></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height=15></td></tr>
</table>
</td>
<td height=60% width=183 valign=top>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td height=60% width=2 background="images/bg_02.gif"></td>
<td height=60% width=181 background="images/bg_03.gif">
<table border=0 cellpadding=0 cellspacing=0 width=181 valign=top>
<tr><td height=5></td></tr>
<tr>
<td>
<table border=0 cellspacing=0 cellpadding=1 width=170 height=250 align=center valign=top bgcolor=#cbcbcb>
<tr>
<td>
<!--友情连接-->
<TABLE height=248 cellSpacing=0 cellPadding=0 width=168 align=center bgColor=#ffffff border=0 valign="top">
<TBODY>
<TR>
<TD vAlign=top><A href="http://www.sh-ec.org.cn/yqlj.asp"><IMG height=33 src="http://www.sh-ec.org.cn/upload/friend_research.JPG" width=168 border="0"></A></TD></TR>
<TR>
<TD vAlign=top> </TD></TR>
<TR>
<TD vAlign=top align=middle><A href="http://www.shanghai.gov.cn" target=_blank><IMG height=46 src="http://www.sh-ec.org.cn/upload/logo_shgov.JPG" width=158 border=0></A><BR></TD></TR>
<TR>
<TD vAlign=top> </TD></TR>
<TR>
<TD vAlign=top align=middle><A href="http://www.shanghaiit.gov.cn" target=_blank><IMG height=55 src="http://www.sh-ec.org.cn/upload/shitgovlogo.JPG" width=159 border=0></A><BR></TD></TR>
<TR>
<TD vAlign=top> </TD></TR>
<TR>
<TD vAlign=top align=middle><A href="http://www.sh-ec.org.cn/wscy_news.asp?id=66" target=_blank ><IMG height=68 src="http://www.sh-ec.org.cn/upload/cecalogo.JPG" width=157 border=0></A><BR></TD></TR>
<TR>
<TD vAlign=top></TD></TR>
<TR>
<TD vAlign=top align=right>
<P><IMG height=7 src="http://www.sh-ec.org.cn/admin/include/images/more.gif" width=35 border=0 target="_blank"></P></TD></TR>
<TR>
<TD vAlign=top align=middle>
<P align="center"><A href="http://www.sh-ec.org.cn/wscy_news.asp?id=66" target=_blank ><IMG height=91 src="http://www.sh-ec.org.cn/upload/seca_mjcn.JPG" width=158 border=0></A></P></TD></TR><TR>
<TD vAlign=top align=middle>
<P align="center"><A href="http://www.sh-ec.org.cn/news.asp?id=820" target=_blank ><IMG height=185 src="http://www.sh-ec.org.cn/upload/shec07report-cover.jpg " width=135 border=0></A></P></TD></TR></TBODY></TABLE>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height=5></td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width=596 border=0 cellpadding=0 cellspacing=0 align=center >
<tr>
<td colspan="4"><a href="hylink.asp"><img src="images/center_3_01.jpg" width="595" border=0></a></td>
</tr>
<tr>
<td height="100" class=td-y1 align="center"><a href="http://www.guanghua.sh.cn" target="_blank"><img border="0" src="images\upload\guanghua.gif" alt="上海复旦光华信息科技股份有限公司" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.oa123.com" target="_blank"><img border="0" src="images\upload\jdhg.gif" alt="上海交大慧谷信息产业股份有限公司" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.easipass.com" target="_blank"><img border="0" src="images\upload\ytgj.gif" alt="上海亿通国际股份有限公司" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.bsteel.com" target="_blank"><img border="0" src="images\upload\dfgt.gif" alt="东方钢铁电子商务有限公司" width="130" height="80"></a></td>
</tr><tr>
<td height="100" class=td-y1 align="center"><a href="http://www.962222.net" target="_blank"><img border="0" src="images\upload\sbzx.gif" alt="上海市社会保障和市民服务信息中心" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.shmec.com.cn" target="_blank"><img border="0" src="images\upload\me.gif" alt="上海爱姆意机电设备连锁有限公司" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.ebay.com.cn" target="_blank"><img border="0" src="images\upload\eachet.gif" alt="亿贝易趣网络信息服务(上海)有限公司" width="130" height="80"></a></td>
<td height="100" class=td-y1 align="center"><a href="http://www.staples.sh.cn" target="_blank"><img border="0" src="images\upload\stb.gif" alt="史泰博商贸有限公司" width="130" height="80"></a></td>
</tr><tr>
</table>
</td>
</tr>
</table>
<style type="text/css">
<!--
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style><TABLE WIDTH=775 BORDER=0 CELLPADDING=0 CELLSPACING=0 align=center>
<TR>
<TD height=1 bgcolor=#9B9B9B></TD>
</TR>
<TR>
<TD height=26 bgcolor=#E5E6E8 class=f2 align=center> 版权所有 </TD>
</TR>
</tr>
<TR>
<TD height=1 bgcolor=#9B9B9B></TD>
</TR>
</TABLE>
</body>
</html>
===============================================
我想把里面以asp为后缀名的文件名保留下来(保留下来的文件名包括后缀名)其他所有的东西都不要,最后生成的结果如下:
===============================================
gywmen.asp|index.asp|xhjs1.asp|hyzj1.asp|xhxx1.asp|hydt1.asp|jlhz1.asp|pxtd1.asp|zcfg1.asp|wscy.asp|wlzwhjj.asp|wsdj.asp|qikan.asp|zddh.asp|lxwm.asp|xhxx1.asp|news.asp|wscy.asp|wscy_news.asp|yqlj.asp|hylink.asp
===============================================
请问能不能用批处理实现
Last edited by HAT on 2009-1-2 at 01:41 ]
Can batch processing achieve this?
|

word |
|
2008-4-1 21:19 |
|
|
w1314ich
中级用户
  
积分 234
发帖 119
注册 2007-4-22
状态 离线
|
|
2008-4-1 21:42 |
|
|
w1314ich
中级用户
  
积分 234
发帖 119
注册 2007-4-22
状态 离线
|
|
2008-4-1 22:24 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
用批处理 可怕很难 因为特殊字符
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
if not "!var!"=="" for /f "delims= " %%i in ("!var!") do if "%%~xi"==".asp" (>>bak.txt echo %%i)
endlocal
)
pause
Using batch processing is terrible and difficult because of special characters
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
if not "!var!"=="" for /f "delims= " %%i in ("!var!") do if "%%~xi"==".asp" (>>bak.txt echo %%i)
endlocal
)
pause
|

简单!简单!再简单! |
|
2008-4-1 22:44 |
|
|
w1314ich
中级用户
  
积分 234
发帖 119
注册 2007-4-22
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
<a href="news.asp?id=842" 中的news.asp不能提取出来
还有 <form name="frm_login" method="post" action="chk_login.asp">
中的chk_login.asp <form action=search.asp method=post ID="Form1" name=Form1> 中的search.asp <a href="xhxx1.asp?id=42"> 中的xhxxq.asp等被忽略了
输出的结果是
gywmen.asp
index.asp
xhjs1.asp
hyzj1.asp
xhxx1.asp
hydt1.asp
jlhz1.asp
pxtd1.asp
zcfg1.asp
wscy.asp
wlzwhjj.asp
http://www.ec315.cn/onlinets.asp
wsdj.asp
qikan.asp
admin/vote/vote_js.asp
zddh.asp
lxwm.asp
wscy.asp
jlhz1.asp
http://www.sh-ec.org.cn/yqlj.asp
Last edited by w1314ich on 2008-4-1 at 11:22 PM ]
gywmen.asp
index.asp
xhjs1.asp
hyzj1.asp
xhxx1.asp
hydt1.asp
jlhz1.asp
pxtd1.asp
zcfg1.asp
wscy.asp
wlzwhjj.asp
http://www.ec315.cn/onlinets.asp
wsdj.asp
qikan.asp
admin/vote/vote_js.asp
zddh.asp
lxwm.asp
wscy.asp
jlhz1.asp
http://www.sh-ec.org.cn/yqlj.asp
Last edited by w1314ich on 2008-4-1 at 11:22 PM ]
|

word |
|
2008-4-1 23:16 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
我搞了个把小时,只能回句太难了,很多提不出来啊,主要是情况太复杂了。
I spent about an hour, and I can only say it's too difficult. Many things can't be extracted. The main thing is the situation is too complicated.
|

批处理之家新域名:www.bathome.net |
|
2008-4-1 23:19 |
|
|
w1314ich
中级用户
  
积分 234
发帖 119
注册 2007-4-22
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
非常感谢 你能把刚刚批处理的注释帮我写写么 最好能详细点 谢谢
Thank you very much. Can you help me write the comments for the just batch processing? It's better to be detailed. Thanks
|

word |
|
2008-4-1 23:29 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
苯办法,文件名中不能含有#号。
:
@echo off
for /f "delims=" %%i in ('findstr /i "\.asp" a.txt') do (
set "var=%%i"
setlocal enabledelayedexpansion
set var=!var:"=!
set var=!var:#=!
set var=!var:"=!
set var=!var:^>=!
set var=!var:^<=!
set var=!var:/==!
set var=!var:.asp=#!
call :loop
endlocal
)
start b.txt
exit
:loop
for /f "delims=#" %%a in ("!var!") do call :lis "%%a"
goto :eof
:lis
for /f "tokens=1* delims==" %%a in ("%~1") do (
if not "%%b"=="" (call :lis "%%b") else >>b.txt echo %%a.asp
)
goto :eof
No good way, the file name cannot contain the # sign.
:
@echo off
for /f "delims=" %%i in ('findstr /i "\.asp" a.txt') do (
set "var=%%i"
setlocal enabledelayedexpansion
set var=!var:"=!
set var=!var:#=!
set var=!var:"=!
set var=!var:^>=!
set var=!var:^<=!
set var=!var:/==!
set var=!var:.asp=#!
call :loop
endlocal
)
start b.txt
exit
:loop
for /f "delims=#" %%a in ("!var!") do call :lis "%%a"
goto :eof
:lis
for /f "tokens=1* delims==" %%a in ("%~1") do (
if not "%%b"=="" (call :lis "%%b") else >>b.txt echo %%a.asp
)
goto :eof
|

致精致简! |
|
2008-4-1 23:43 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
set var=!var:?= !
set var=!var:^>= !
set var=!var:^<= !
if not "!var!"=="" for /f "tokens=1* delims= " %%i in ("!var!") do if "%%~xi"==".asp" (>>bak.txt echo %%i) else call :lp "%%j"
endlocal
)
pause
goto :eof
:lp
for /f "tokens=1* delims= " %%i in ("%~1") do if "%%~xi"==".asp" (>>bak.txt echo %%i&goto :eof) else call :lp "%%j"
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
set var=!var:?= !
set var=!var:^>= !
set var=!var:^<= !
if not "!var!"=="" for /f "tokens=1* delims= " %%i in ("!var!") do if "%%~xi"==".asp" (>>bak.txt echo %%i) else call :lp "%%j"
endlocal
)
pause
goto :eof
:lp
for /f "tokens=1* delims= " %%i in ("%~1") do if "%%~xi"==".asp" (>>bak.txt echo %%i&goto :eof) else call :lp "%%j"
|

简单!简单!再简单! |
|
2008-4-1 23:45 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
发了才知道有了
Just sent it and then realized it was already there
|

简单!简单!再简单! |
|
2008-4-1 23:47 |
|
|
ThinKing
中级用户
  
积分 471
发帖 207
注册 2007-5-3
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
为什么不直接: grep -oE "\w+\.asp" urfile.html
呢?
Why not directly:
grep -oE "\w+\.asp" urfile.html
|
|
2008-4-2 08:11 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by w1314ich at 2008-4-1 23:29:
非常感谢 你能把刚刚批处理的注释帮我写写么 最好能详细点 谢谢
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
set var=!var:?= !
set var=!var:^>= !
set var=!var:^<= !
if not "!var!"=="" for /f "tokens=1* delims= " %%i in ("!var!") do if "%%~xi"==".asp"
(>>bak.txt echo %%i) else call :lp "%%j"
endlocal
)
pause
goto :eof
:lp
for /f "tokens=1* delims= " %%i in ("%~1") do if "%%~xi"==".asp" (>>bak.txt echo %%i&goto
:eof) else call :lp "%%j"
应楼主要求并尽我的能力为TERSE的这段精彩代码写下解释如下(如有错误和不到之处请谅解并指教):
批处理首先通过第一个for循环开启变量延迟以":"为分隔符对a.txt中每段字符串中的特殊字符(:"")进行变量替换为无,同时将特殊字符(?><)替换为空格" "(是为后面的for循环中delims= 做准备工作);
然后对替换后的这段字符串进行if判断是否为空,如不是空就进入第二个for循环又用if对以" "为分格符的第一个字符串%%i进行判断是否含有以.asp为后缀名的文件名(在这里使用了变量扩充%%~xi将变量%%i扩充到文件扩展名),如果有则将这串字符(%%i)添加输入到back.txt中,如不含有(else)则跳转到标签为lp的下一个for循环,并将%%i后所有字串符"%%j变量"传递给下一个for循环(注意在这里用双引号将%%j引起来是为了使下一个for循环中能正确识别含有空格的变量%%j);
在最后一个for循环中其实是不断重复前一个for循环的工作直到最后一个后缀名为.asp的字符串被取出添加到back.txt中,只不过是要在这里运用%%~1去除变量的双引号扩充变量%%~1(从上一个for循环中传递过来的加了双引号的变量"%%j")。
又是一个很难解释的过程,汗。。。。。。。。。。。。。。。
Last edited by zw19750516 on 2008-4-2 at 01:41 PM ]
Originally posted by w1314ich at 2008-4-1 23:29:
Thank you very much. Can you write the comments for the just batch processing for me? It's better to be detailed. Thanks
@echo off
for /f "tokens=* delims=:" %%a in ('findstr /n "\.asp" a.txt') do (
set var=%%a
setlocal enabledelayedexpansion
set var=!var:*:=!
set var=!var:*"=!
set var=!var:"= !
set var=!var:?= !
set var=!var:^>= !
set var=!var:^<= !
if not "!var!"=="" for /f "tokens=1* delims= " %%i in ("!var!") do if "%%~xi"==".asp"
(>>bak.txt echo %%i) else call :lp "%%j"
endlocal
)
pause
goto :eof
:lp
for /f "tokens=1* delims= " %%i in ("%~1") do if "%%~xi"==".asp" (>>bak.txt echo %%i&goto
:eof) else call :lp "%%j"
At the request of the poster and to the best of my ability, the following is the explanation for TERSE's wonderful code (please forgive and give advice if there are errors and deficiencies):
The batch processing first uses the first for loop to enable variable delay, uses ":" as the delimiter to replace special characters (:"") in each segment of the string in a.txt with nothing, and replaces special characters (?><) with space " " (this is to prepare for the delims= in the subsequent for loop);
Then, it performs an if judgment on the replaced string to see if it is empty. If it is not empty, it enters the second for loop, and again uses if to judge the first string %%i with " " as the delimiter to see if there is a file name with.asp as the suffix name (here, variable expansion %%~xi is used to expand variable %%i to the file extension). If there is, it adds this string (%%i) to the input back.txt. If not (else), it jumps to the next for loop with the label lp, and passes the substring "%%j variable" after %%i to the next for loop (note that enclosing %%j in double quotes here is to enable the next for loop to correctly identify the variable %%j with spaces);
In the last for loop, it is actually constantly repeating the work of the previous for loop until the last string with.asp as the suffix is taken out and added to back.txt. It's just that here, %%~1 is used to remove the double quotes of the variable and expand the variable %%~1 (the variable "%%j" with double quotes passed from the previous for loop).
Another very difficult process to explain, sweat......
Last edited by zw19750516 on 2008-4-2 at 01:41 PM ]
|

批处理之家新域名:www.bathome.net |
|
2008-4-2 13:32 |
|
|
bjsh
银牌会员
    
积分 2000
发帖 621
注册 2007-1-1
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
如果是我的话, 我会用python来解析。
还算相当简单的吧, 效率当然比批处理更高。。。
If it were me, I would use Python to parse it. It's still quite simple, and of course, the efficiency is higher than batch processing...
|
|
2008-4-2 14:38 |
|
|
abcd
银牌会员
    
积分 1436
发帖 739
注册 2007-10-11
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
处理此问题,VBS更简单高效。
何必在一棵树上吊死呢?
For handling this problem, VBS is simpler and more efficient. Why stick to one option only?
|
|
2008-4-2 14:47 |
|
|
bat-zw
金牌会员
      永远的学习者
积分 3105
发帖 1276
注册 2008-3-8
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
我不同意abcd的意见,我们处理这个问题是为了得到提高,不为了别的。
Last edited by zw19750516 on 2008-4-2 at 02:52 PM ]
I disagree with the opinions of abcd. We are dealing with this problem to achieve improvement, and for no other reason.
Last edited by zw19750516 on 2008-4-2 at 02:52 PM ]
|

批处理之家新域名:www.bathome.net |
|
2008-4-2 14:51 |
|