原帖由 namejm 于 2009-4-12 09:35 发表
因为论坛会存在转码现象,有可能对原始数据做出错误的处理,建议在正文中只发部分有代表性的数据,并在附件中上传部分原始数据,以保证数据格式不发生变化,同时能节约版面。
因为文件较大,纯批处理估计 ...
@echo off&setlocal enabledelayedexpansion
set ho=UNITED STATES OF AMERICA (US)
set en=PATENT (Number; Kind; Date):
set bg=United States of America (US)
set li2=BASIC-PATENT:
set li10=European Patent Office (EP)
set li11=Russian Federation (RU)
set li12=World Intellectual Property Organisation (WO)
set li13=Canada (CA)
set li14=People's Republic of China (CN)
set li15=Japan (JP)
set li16=Republic of Korea (KR)
set li17=United Kingdom (GB)
set li18=Germany (DE)
set li19=France (FR)
set li20=United States of America (US)
::国家判断只对比了前面10个字节,应该可以了的。
for /f %%a in ('dir /b *.txt') do (
set "ver="
(for /f "delims=" %%d in (%%a) do (set "str=%%d"&call :sub))>%%~na_dest.txt
start %%~na_dest.txt
)
echo 处理完成
pause
goto :eof
:sub
if defined ver (echo.!str!
if not "!str:%en%=!"=="!str!" set ver=
goto :eof)
if not "!str:%li2%=!"=="!str!" echo !str!&goto :eof
if "!str:%en%=!"=="!str!" (
if "!str!"=="!ho!" (set vho=y&goto :eof) else (set vho=)
goto :eof
) else (
set "coc=!str:*%en% =!"
if defined vho (
if "!bg:~0,10!"=="!coc:~0,10!" (set vho=&set ver=y&echo !ho!&echo.!str!&goto :eof)
)
for /l %%a in (10,1,20) do (if "!li%%a:~0,10!"=="!coc:~0,10!" echo !str!&goto :eof)
)
goto :eof
File_Path=WScript.arguments(0);
var sss,arr="",osss="";
var fso=new ActiveXObject("scripting.filesystemobject");
var fl=fso.opentextfile(File_Path,1);sss=fl.readall();
fl=fso.opentextfile(File_Path+"_转换后.txt",2,true);
var re=/(?:^|\r\n) ?BASIC-PATENT:|\r\nUNITED STATES OF AMERICA \(US\)\s*PATENT \(Number; Kind; Date\): United States of America \(US\)[\s\S]*?\r\nPATENT \(Number; Kind; Date\)\:.*|PATENT \(Number; Kind; Date\): European Patent Office \(EP\).*|PATENT \(Number; Kind; Date\): United States of America \(US\).*|PATENT \(Number; Kind; Date\): World Intellectual Property Organisation \(WO\).*|PATENT \(Number; Kind; Date\): Canada \(CA\).*|PATENT \(Number; Kind; Date\): People's Republic of China \(CN\).*|PATENT \(Number; Kind; Date\): Japan \(JP\).*|PATENT \(Number; Kind; Date\): Republic of Korea \(KR\).*|PATENT \(Number; Kind; Date\): United Kingdom \(GB\).*|PATENT \(Number; Kind; Date\): Germany \(DE\).*|PATENT \(Number; Kind; Date\): France \(FR\).*|PATENT \(Number; Kind; Date\): Russian Federation \(RU\).*\:.*/g
while ((arr=re.exec(sss))!=null)osss=osss+arr+"\r\n";
fl.write(osss);
WScript.echo("ok")
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |