【发布时间】:2015-12-14 06:20:06
【问题描述】:
我想使用批处理文件在文本文件中查找一个单词,然后我想删除包含该单词的行并删除下面的其他一些行,例如:
# Materials file generated by ZModeler 2.2.6 (Build 992).
newmtl Black__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.15 0.15 0.15
illum 1
newmtl Carbon__CarPaint_
Ka 0.69 0.69 0.69
Kd 0.69 0.69 0.69
Ks 0.60 0.60 0.60
illum 1
map_Kd carbon.dds
refl cubeint.dds
newmtl Chrome__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 1.00 1.00 1.00
illum 1
refl cubeint.dds
newmtl Details_Int__Default_A_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.30 0.30 0.30
illum 1
map_Kd apollo_2008_details_int.dds
bump apollo_2008_details_int_ts.dds
newmtl Details_Int2__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.40 0.40 0.40
illum 1
map_Kd apollo_2008_details_int2.dds
refl cubeint.dds
newmtl C1_Lea__Default_N_
Ka 0.95 0.46 0.07
Kd 0.95 0.46 0.07
Ks 0.10 0.10 0.10
illum 1
map_Kd moket2.dds
bump ts_leather3.dds
newmtl MAT_1__CarPaint_
Ka 0.69 0.69 0.69
Kd 0.69 0.69 0.69
Ks 0.60 0.60 0.60
illum 1
map_Kd carbon.dds
refl cubeint.dds
newmtl Moquette__Default_
Ka 0.36 0.36 0.36
Kd 0.36 0.36 0.36
Ks 0.20 0.20 0.20
illum 1
map_Kd moquette1.dds
newmtl Paint__CarPaint2_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 1.00 1.00 1.00
illum 2
Ns 100.000000
bump fio_damage_2.dds
refl cubemap.dds
map_Kd user_tex.dds
map_Kd impact_maps.dds
newmtl Red__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.20 0.20 0.20
illum 1
newmtl Screen__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.20 0.20 0.20
illum 1
refl cubeint.dds
newmtl Plastic__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.20 0.20 0.20
illum 1
newmtl Alcantara__CarVelour_
Ka 0.37 0.37 0.37
Kd 0.37 0.37 0.37
Ks 1.00 1.00 1.00
illum 2
Ns 100.000000
map_Kd moket2.dds
bump ts_moket2.dds
map_Ks moket2.dds
newmtl Details_Int_Alp__Default_A___GLT_
Ka 0.21 0.21 0.21
Kd 0.21 0.21 0.21
Ks 0.80 0.80 0.80
illum 2
Ns 80.000000
map_Kd apollo_2008_details_int.dds
bump apollo_2008_details_int_ts.dds
map_Ks apollo_2008_details_int.dds
refl cubeint.dds
newmtl Details_Int_Alp__Default_A___GLT_
Ka 0.23 0.23 0.23
Kd 0.23 0.23 0.23
Ks 0.20 0.20 0.20
illum 2
Ns 10.000000
map_Kd apollo_2008_details_int.dds
bump apollo_2008_details_int_ts.dds
map_Ks apollo_2008_details_int.dds
newmtl Details_Int2_Al__CarPaint_
Ka 0.95 0.95 0.95
Kd 0.95 0.95 0.95
Ks 0.10 0.10 0.10
illum 1
map_Kd apollo_2008_details_int2.dds
newmtl HUD__DashBoard_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.30 0.30 0.30
illum 1
map_Kd apollo_2008_details_int.dds
refl cubeint.dds
newmtl Patch__Default_A_
Ka 0.44 0.44 0.44
Kd 0.44 0.44 0.44
Ks 0.00 0.00 0.00
illum 1
map_Kd apollo_2008_details_int2.dds
bump apollo_2008_details_int2_ts.dds
newmtl A_C2_C__Default_A___GLT_
Ka 0.89 0.53 0.15
Kd 0.89 0.53 0.15
Ks 0.10 0.10 0.10
illum 2
Ns 10.000000
map_Kd couture.dds
bump ts_couture.dds
map_Ks couture.dds
newmtl Leather__Default_N_
Ka 0.36 0.36 0.36
Kd 0.36 0.36 0.36
Ks 0.10 0.10 0.10
illum 1
map_Kd moket2.dds
bump ts_leather3.dds
newmtl HUD_01__DashBoard_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.30 0.30 0.30
illum 1
map_Kd apollo_2008_details_int.dds
refl cubeint.dds
newmtl C3_L__Default_N_
Ka 1.00 0.60 0.00
Kd 1.00 0.60 0.00
Ks 0.10 0.10 0.10
illum 1
map_Kd moket2.dds
bump ts_leather3.dds
newmtl A_C1_P__Default_A_
Ka 1.00 0.51 0.18
Kd 1.00 0.51 0.18
Ks 0.10 0.10 0.10
illum 1
map_Kd apollo_2008_details_int2.dds
bump apollo_2008_details_int2_ts.dds
newmtl Belt__Default_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.20 0.20 0.20
illum 2
Ns 10.000000
map_Kd seatbelt.dds
map_Ks seatbelt.dds
newmtl Grip__Default_N_
Ka 0.35 0.35 0.35
Kd 0.35 0.35 0.35
Ks 0.20 0.20 0.20
illum 2
Ns 10.000000
map_Ks dot2.dds
bump ts_dot2.dds
newmtl Plastic2__CarPaint_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.20 0.20 0.20
illum 1
newmtl A_C2_CC__Default_A___GLT_
Ka 0.89 0.53 0.15
Kd 0.89 0.53 0.15
Ks 0.10 0.10 0.10
illum 2
Ns 10.000000
map_Kd couture_croix.dds
bump couture_croix_ts.dds
map_Ks couture_croix.dds
newmtl C3_Pla__Default_
Ka 0.29 0.29 0.29
Kd 0.29 0.29 0.29
Ks 0.20 0.20 0.20
illum 1
newmtl Glass_I__CarGlassDirt_
Ka 1.00 1.00 1.00
Kd 1.00 1.00 1.00
Ks 0.00 0.00 0.00
illum 4
map_Kd apollo_2008_glass_i.dds
如您所见,每个短语的格式都与其他短语相同
newmtl A_C2_CC__Default_A___GLT_ :The material name
Ka 0.89 0.53 0.15 :Some of the numbers for transparency reflection and ...
Kd 0.89 0.53 0.15 :Some of the numbers for transparency reflection and ...
Ks 0.10 0.10 0.10 :Some of the numbers for transparency reflection and ...
illum 2 :One illum
Ns 10.000000 :Some of the numbers for transparency reflection and ...
map_Kd couture_croix.dds :Texture names
bump couture_croix_ts.dds :Texture names
map_Ks couture_croix.dds :Texture names
好的,例如,我想找到 newmtl A_C2_CC__Default_A___GLT_ 或材料名称的一部分,然后我想告诉它将 illum 2 更改为 illum 4,材料名称下的 3 行是 illum,但它可能会改变,所以我想要告诉它首先找到材料名称,然后找到第一个 illum,然后删除该行并改写 illum 4。
我正在编写代码,但一天之内我什么也得不到
【问题讨论】:
标签: batch-file replace find text-files