|
tianzizhi
高级用户
   
积分 622
发帖 214
注册 2006-9-22
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
我试过了, www.txt文件里的内容就一行的,没有换行,难怪我试了好多都不正确.我弄一小段文件回车后用ccwan的代码可以,误差有一点.
如不回车,就这么长的一行有办法提取出来.htm结尾的么,用第三方工具也行,大家没事了想想怎么才能做到,呵呵.......
I tried it. The content in the www.txt file is just one line without line breaks. No wonder many of my attempts were incorrect. I made a small segment of the file and after pressing enter, the code of ccwan works, but there is a little error.
If there is no enter, just such a long single line, is there a way to extract it with a.htm ending? It's okay to use third-party tools. Everyone can think about how to do it when free, hehe.......
|

QQ:419503077 |
|
2006-12-26 06:12 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
 『第 17 楼』:
使用 LLM 解释/回答一下
sed "s/htm/\n/" life|sed "/.htm/!d"|sed "s/.* 200/200/;s/.htm.*/.htm/"|more>a.txt
type a.txt
pause>nul
Last edited by vkill on 2006-12-26 at 06:35 AM ]
sed "s/htm/\n/" life|sed "/.htm/!d"|sed "s/.* 200/200/;s/.htm.*/.htm/"|more>a.txt
type a.txt
pause>nul
Last edited by vkill on 2006-12-26 at 06:35 AM ]
|
|
2006-12-26 06:27 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
呵呵,sed awk解决文字很容易了
Hehe, sed and awk are very easy for handling text
|
|
2006-12-26 06:30 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
|
2006-12-26 06:54 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
找了半天,没找到文件的规律~
After searching for a long time, I didn't find the pattern of the files.
|
|
2006-12-26 10:21 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
'终于找到了解决方法,把下面的代码存为VBS
'你要处理的文件 www.txt和这个VBS文件一定要在一个目录.
on error resume next
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile("www.txt",1)
a=file.readall
file.close
i=0
do
i=instr(i+1,a,".htm")
if i<>0 then b=b & mid(a,i-12,16)& vbcrlf
loop until i=0
set file=fso.createtextfile("222.txt")
file.write b
file.close
msgbox "文件处理完毕,请查看222.txt文件",48+4096,"操作成功"
Last edited by jmz573515 on 2006-12-26 at 08:44 AM ]
Finally found the solution. Save the following code as a VBS.
The file you want to process www.txt and this VBS file must be in the same directory.
on error resume next
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile("www.txt",1)
a=file.readall
file.close
i=0
do
i=instr(i+1,a,".htm")
if i<>0 then b=b & mid(a,i-12,16)& vbcrlf
loop until i=0
set file=fso.createtextfile("222.txt")
file.write b
file.close
msgbox "File processing completed, please check the 222.txt file",48+4096,"Operation successful"
Last edited by jmz573515 on 2006-12-26 at 08:44 AM ]
此帖被 +12 点积分 点击查看详情 评分人:【 namejm 】 | 分数: +4 | 时间:2006-12-26 21:44 | 评分人:【 tianzizhi 】 | 分数: +4 | 时间:2006-12-26 23:10 | 评分人:【 lxmxn 】 | 分数: +4 | 时间:2006-12-27 02:14 |
|
|
|
2006-12-26 21:17 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
按照你的提示,把 www.txt和那个vbs放在同一目录下操作,但是还是出错了。
According to your prompt, I put www.txt and that vbs in the same directory for operation, but it still went wrong.
附件
1: 出错.JPG (2006-12-26 21:31, 9.48 KiB, 下载附件所需积分 1 点
,下载次数: 6)
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-12-26 21:31 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
晕~~
我试了多遍都没有问题,你要处理的文件名是不是 www.txt?
如果还不行你可以试一下,把 www.txt改成11.txt之后把vbs里的 www.txt也改成11.txt看看行不行.
Oh, dizziness~~
I've tried many times and there's no problem. Is the file name you need to handle www.txt?
If it still doesn't work, you can try changing www.txt to 11.txt and then also change www.txt in the vbs to 11.txt to see if it works.
|
|
2006-12-26 21:36 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
犯了个低级错误:复制代码的时候,把最开始的 ' 漏掉了。建议把代码部分用 [code] 和 [/code] 括起来,以方便别人的复制。
Made a rookie mistake: when copying the code, I missed the initial '. It is suggested to enclose the code part with and
to facilitate others' copying.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-12-26 21:42 |
|
|
tianzizhi
高级用户
   
积分 622
发帖 214
注册 2006-9-22
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
vbs确实厉害,不过现在还不能去学它,现在还要学我的c,以后试着用c解决我遇到的问题.
VBS is indeed powerful, but I can't learn it right now. I still need to study my C. I'll try to use C to solve the problems I encounter in the future.
|

QQ:419503077 |
|
2006-12-26 23:13 |
|
|
netbenton
银牌会员
     批处理编程迷
积分 1916
发帖 752
注册 2008-12-28 来自 广西
状态 离线
|
『第 26 楼』:
顶起陈年老贴,来迟了,呵呵
使用 LLM 解释/回答一下
@echo off&setlocal enabledelayedexpansion
set "t="
(for /f "tokens=*" %%a in (www.txt) do (set "str=!t!%%a"&set "t=%%a"&call :sub !str!))>dest.txt
start dest.txt
pause
goto :eof
:sub
if /i "%~x1"==".htm" echo %1
shift
if not "%1"=="" goto :sub
set t=!t:.htm=!
goto :eof
来一个纯批的!
```
@echo off&setlocal enabledelayedexpansion
set "t="
(for /f "tokens=*" %%a in (www.txt) do (set "str=!t!%%a"&set "t=%%a"&call :sub !str!))>dest.txt
start dest.txt
pause
goto :eof
:sub
if /i "%~x1"==".htm" echo %1
shift
if not "%1"=="" goto :sub
set t=!t:.htm=!
goto :eof
```
A purely batch one!
|

精简
=> 个人 网志  |
|
2009-4-12 08:55 |
|
|
freeants001
中级用户
  
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
我怎么下不了附件!~~~
Why can't I download the attachment!~~~
|
|
2009-4-12 09:20 |
|
|
freeants001
中级用户
  
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
来个混血的
more +4 "%~f0">#js.js
cscript /nologo #js.js 文件.txt
goto:eof
:::::::::::::::::::::::
File_Path=WScript.arguments(0);
var fso=new ActiveXObject("scripting.filesystemobject");
var fl=fso.opentextfile(File_Path,1);
var sss=fl.readall();
var fl=fso.opentextfile(File_Path+"_处理后.txt",2,1);
sss=sss.replace(/*?\s+(\d+\.htm)/g,"$1\r\n");
fl.write(sss);
A hybrid one
more +4 "%~f0">#js.js
cscript /nologo #js.js 文件.txt
goto:eof
:::::::::::::::::::::::
File_Path=WScript.arguments(0);
var fso=new ActiveXObject("scripting.filesystemobject");
var fl=fso.opentextfile(File_Path,1);
var sss=fl.readall();
var fl=fso.opentextfile(File_Path+"_处理后.txt",2,1);
sss=sss.replace(/*?\s+(\d+\.htm)/g,"$1\r\n");
fl.write(sss);
|
|
2009-4-12 09:50 |
|