标题: [文本处理] 批处理怎样提取文本? [打印本页]
作者: mengzhiyuan 时间: 2011-4-25 16:03 标题: 批处理怎样提取文本?
比如文本文件1.txt内容如下
U Percentage = 47.310368633
V Percentage = 13.429474740
Point on Face XC = -7.206359227 X = -7.206359227
YC = 0.207949979 Y = 0.207949979
ZC = 21.642631315 Z = 21.642631315
U First Derivative XC = 14.155746145 X = 14.155746145
YC = -82.965589343 Y = -82.965589343
ZC = 0.000000000 Z = 0.000000000
V First Derivative XC = 0.000000000 X = 0.000000000
YC = 0.000000000 Y = 0.000000000
ZC = -25.000000000 Z = -25.000000000
Unit Face Normal XC = 0.985754378 X = 0.985754378
YC = 0.168191281 Y = 0.168191281
ZC = 0.000000000 Z = 0.000000000
Principal Radii of Curvature
Minimum = -13.395206706
Maximum = Infinite
------------------------------------------------------------
Geometric properties for face
Information Units mm
U Percentage = 45.290722375
V Percentage = 84.025423921
Point on Face XC = -7.597661914 X = -7.597661914
YC = 1.860952417 Y = 1.860952417
ZC = 3.993644020 Z = 3.993644020
U First Derivative XC = 24.541866779 X = 24.541866779
YC = -80.506962053 Y = -80.506962053
ZC = 0.000000000 Z = 0.000000000
V First Derivative XC = 0.000000000 X = 0.000000000
YC = 0.000000000 Y = 0.000000000
ZC = -25.000000000 Z = -25.000000000
Unit Face Normal XC = 0.956542235 X = 0.956542235
YC = 0.291593814 Y = 0.291593814
ZC = 0.000000000 Z = 0.000000000
Principal Radii of Curvature
Minimum = -13.395206706
Maximum = Infinite
我想提取Point on Face后XC,YC,ZC,unit Face Normal X,Y,Z值,保留小数点4位,并输出到新的文本文件2.txt中格式如下
1 -7.2063 0.2079 21.6426 0.9857 0.1681 0.0000
2 -7.5976 1.8609 3.9936 0.9565 0.2915 0.0000
请高手指点怎么写批处理,
作者: batman 时间: 2011-4-25 19:40
本帖最后由 batman 于 2011-4-25 19:48 编辑
有点麻烦:- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in (1.txt) do (
- for /f "tokens=1" %%b in ("%%a") do (
- for %%c in (Point Unit) do if "%%b" equ "%%c" set "flag=a"
- if defined flag (
- for /f "tokens=2,3 delims==" %%b in ("%%a") do (
- set /a n+=1
- if !n! leq 3 (
- set "a=%%b"&set "b=%%c"
- for %%a in (a b) do (
- for /f "tokens=1,2 delims=." %%b in ("!%%a!") do set "xs=%%c"&set "_%%a=!_%%a! %%b.!xs:~,4!"
- )
- ) else (
- set "flag="&set /a n=0
- )
- )
- )
- )
- )
- (for %%a in (a b) do echo !_%%a:~1!)>2.txt
- start 2.txt
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |