|
米娜
初级用户
 
积分 147
发帖 20
注册 2003-1-11
状态 离线
|
『楼 主』:
[求助]笨丫头想不出问题,批处理xml文件
使用 LLM 解释/回答一下
欲做一批处理,将xml文件中的某一字符替换,
xml文件中的代码:
……
……
……
grid_menu_bg="xin003.jpg"/>
……
……
……
欲在grid_menu_bg="xin003.jpg" 后边添加代码idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/>
既,批处理后的代码是 :
grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/>
啊:把:
grid_menu_bg="xin003.jpg"/> 改成 grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/>
可代码中的 xin003.jpg 的 xin003 是随机的,
呵呵,我知道很高难度~~~~~
Want to make a batch processing to replace a certain character in the xml file,
The code in the xml file:
……
……
……
grid_menu_bg="xin003.jpg"/>
……
……
……
Want to add code idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/> after grid_menu_bg="xin003.jpg"
That is, the code after batch processing is:
grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/>
Ah: change:
grid_menu_bg="xin003.jpg"/> to grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png"/>
But the xin003 in xin003.jpg in the code is random,
Hehe, I know it's very difficult~~~~~
|
|
2007-2-16 11:17 |
|
|
gne3
高级用户
    DOS学徒
积分 526
发帖 252
注册 2007-2-12
状态 离线
|
|
2007-2-16 22:29 |
|
|
amao
中级用户
  
积分 316
发帖 152
注册 2006-6-18
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
发一段你的xml代码上来,这样看不出规律,没法帮你
Please provide the XML code you want to translate.
|
|
2007-2-16 22:48 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
有这个grid_menu_bg的行?
Is there a line with this grid_menu_bg?
|
|
2007-2-17 00:47 |
|
|
0451lym
高级用户
   
积分 760
发帖 357
注册 2005-10-10
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
@echo off
:00
SET 字符串=grid_menu_bg
strings 新字符串=READ 新字符串.TXT,1
SET 文件名=xml
SET 新文件=新文件.TXT
SET 取字符串数=1,25
SET 行数=1
:11
SET X=>NUL
strings x=read %文件名%,行数
if "x"=="" goto 退出
strings 行数=add %行数%,1
ECHO %X%|FIND /I "%字符串%">NUL
if ERRORLEVEL 1 goto 写旧文件
:写新文件
STRINGS X=MID %X%,%取字符串数%
ECHO %X%%新字符串%>>%新文件%
GOTO 11
:写旧文件
ECHO %X%>>%新文件%
GOTO 11
:退出
for %%x in (X 字符串 新字符串 文件名 新文件 取字符串数 行数) do SET %%x=>NUL
CLS
ECHO 工作已经完成,请验收!
Last edited by 0451lym on 2007-2-17 at 08:06 AM ]
@echo off
:00
SET string=grid_menu_bg
strings new_string=READ new_string.TXT,1
SET file_name=xml
SET new_file=new_file.TXT
SET take_string_count=1,25
SET line_number=1
:11
SET X=>NUL
strings x=read %file_name%,%line_number%
if "x"=="" goto exit
strings line_number=add %line_number%,1
ECHO %X%|FIND /I "%string%">NUL
if ERRORLEVEL 1 goto write_old_file
:write_new_file
STRINGS X=MID %X%,%take_string_count%
ECHO %X%%new_string%>>%new_file%
GOTO 11
:write_old_file
ECHO %X%>>%new_file%
GOTO 11
:exit
for %%x in (X string new_string file_name new_file take_string_count line_number) do SET %%x=>NUL
CLS
ECHO The work has been completed, please check!
Last edited by 0451lym on 2007-2-17 at 08:06 AM ]
|
|
2007-2-17 02:53 |
|
|
米娜
初级用户
 
积分 147
发帖 20
注册 2003-1-11
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
文件里的代码是没有规律的,所出现的常量一样,但数值不一样的。
abc..xml文件的代码如下(一个给手机做主题的代码,其中的图片文件名是随机的,不用修改,只是改一部分,添加一些代码,就是在红色部分的代码中添加,):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE theme PUBLIC "-//NOKIA//DTD THEME 2.0//EN" "theme.dtd">
<theme name="chun1" version="2.0">
<colors
display="main"
status_area_font_color="0x0"
calendar_highlight_color="0xccffcc" />
<wallpaper
main_display_graphics="026.jpg" />
<screensaver
main_display_graphics="025.jpg" />
<background
main_default_bg="xin003.jpg"
grid_menu_bg="xin003.jpg" />
<calendar_bg
january="xin003.jpg"
february="xin003.jpg"
march="xin003.jpg"
april="xin003.jpg"
may="xin003.jpg"
june="xin003.jpg"
july="xin003.jpg"
august="xin003.jpg"
september="xin003.jpg"
october="xin003.jpg"
november="xin003.jpg"
december="xin003.jpg" />
<highlight
list="32.png" />
<startup
main_display_graphics="026.jpg" />
<shutdown
main_display_graphics="026.jpg" />
<transformation_open
main_display_graphics="026.jpg" />
<transformation_close
main_display_graphics="026.jpg" />
</theme>
使 grid_menu_bg="xin003.jpg" /> 变为 grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png" />
注:黑色部分是要添加的代码,
其中 grid_menu_bg= 后的 "xin003.jpg" 可能是 "xin066.jpg" 或是 "xin055.jpg" 或是别的什么图片格式的文件,不用改~~~
The code in the file has no pattern. The constants that appear are the same, but the values are different.
The code of the abc..xml file is as follows (a code for making themes for mobile phones. The file names of the pictures are random and do not need to be modified. Just modify some parts and add some code, that is, add in the code of the red part):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE theme PUBLIC "-//NOKIA//DTD THEME 2.0//EN" "theme.dtd">
<theme name="chun1" version="2.0">
<colors
display="main"
status_area_font_color="0x0"
calendar_highlight_color="0xccffcc" />
<wallpaper
main_display_graphics="026.jpg" />
<screensaver
main_display_graphics="025.jpg" />
<background
main_default_bg="xin003.jpg"
grid_menu_bg="xin003.jpg" />
<calendar_bg
january="xin003.jpg"
february="xin003.jpg"
march="xin003.jpg"
april="xin003.jpg"
may="xin003.jpg"
june="xin003.jpg"
july="xin003.jpg"
august="xin003.jpg"
september="xin003.jpg"
october="xin003.jpg"
november="xin003.jpg"
december="xin003.jpg" />
<highlight
list="32.png" />
<startup
main_display_graphics="026.jpg" />
<shutdown
main_display_graphics="026.jpg" />
<transformation_open
main_display_graphics="026.jpg" />
<transformation_close
main_display_graphics="026.jpg" />
</theme>
Change grid_menu_bg="xin003.jpg" /> to grid_menu_bg="xin003.jpg" idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png" />
Note: The black part is the code to be added,
Among them, "xin003.jpg" after grid_menu_bg= may be "xin066.jpg" or "xin055.jpg" or other image format files, no need to change~~~
|
|
2007-2-17 07:04 |
|
|
0451lym
高级用户
   
积分 760
发帖 357
注册 2005-10-10
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
晕,这么简单的东西还没弄明白?
都已经给你写的很完美了.开头的改一下就可以了.
SET 字符串=grid_menu_bg
strings 新字符串=READ 新字符串.TXT,1
SET 文件名=xml
SET 新文件=新文件.TXT
SET 取字符串数=1,25
SET 行数=1
-----------------------------------------------------------
在创建一个新的文件取名叫"新字符串.TXT",在里面把
idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png" />
写进去就可以了
Last edited by 0451lym on 2007-2-17 at 08:07 AM ]
Oh, so confusing, you still haven't figured out something so simple? It's already written perfectly for you. Just change the beginning.
SET 字符串=grid_menu_bg
strings 新字符串=READ 新字符串.TXT,1
SET 文件名=xml
SET 新文件=新文件.TXT
SET 取字符串数=1,25
SET 行数=1
-----------------------------------------------------------
Create a new file named "新字符串.TXT" and write the following inside:
idle_status_area_bg="spacer.png" idle_softkey_area_bg="spacer.png" />
Last edited by 0451lym on 2007-2-17 at 08:07 AM ]
|
|
2007-2-17 07:37 |
|
|
0451lym
高级用户
   
积分 760
发帖 357
注册 2005-10-10
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
给你解释解释批处理的意思!
蓝色的部分为著译.
@echo off
:00
REM 把要找的内容设置变量,取其最为独特的字符串,不一定是全部
SET 字符串=grid_menu_bg
REM 把要加入的字符串设置为变量,需要先在新字符串.TXT中写入完整字符串
strings 新字符串=READ 新字符串.TXT,1
REM 把要修改的文件设置为变量
SET 文件名=xml
REM 把修改后的文件设置为变量
SET 新文件=新文件.TXT
REM 原文件中要截取保留的字符串内容
SET 取字符串数=1,25
REM 设置原始文件开始行数为1
SET 行数=1
:11
REM 清空变量X
SET X=>NUL
REM 读取原文件的某行,设置为变量X
strings x=read %文件名%,行数
REM 如果读取为最后一行,那么退出
if "x"=="" goto 退出
REM 设置行数加1,即确定下一次读取的下一行
strings 行数=add %行数%,1
REM 检查变量X中有没有需要修改的字符串行
ECHO %X%|FIND /I "%字符串%">NUL
REM 如果没有,那么跳转到写旧文件标记
if ERRORLEVEL 1 goto 写旧文件
:写新文件
REM X中有所需要修改的字符串行,取得所要保留的字符串部分
STRINGS X=MID %X%,%取字符串数%
REM 把保留的字符串部分和需要加入的字符串部分写入到新文件
ECHO %X%%新字符串%>>%新文件%
GOTO 11
:写旧文件
REM 把不需要修改的旧文件行写入到新文件
ECHO %X%>>%新文件%
GOTO 11
:退出
REM 清除所有变量
for %%x in (X 字符串 新字符串 文件名 新文件 取字符串数 行数) do SET %%x=>NUL
CLS
ECHO 工作已经完成,请验收!
Last edited by 0451lym on 2007-2-17 at 08:05 AM ]
Explain the meaning of batch processing!
The blue part is the translation.
@echo off
:00
REM Set the content to be found as a variable, take its most unique string, not necessarily the whole
SET 字符串=grid_menu_bg
REM Set the string to be added as a variable, need to write the complete string in new string.TXT first
strings 新字符串=READ 新字符串.TXT,1
REM Set the file to be modified as a variable
SET 文件名=xml
REM Set the modified file as a variable
SET 新文件=新文件.TXT
REM The string content to be intercepted and retained in the original file
SET 取字符串数=1,25
REM Set the starting line number of the original file to 1
SET 行数=1
:11
REM Clear variable X
SET X=>NUL
REM Read a line of the original file and set it as variable X
strings x=read %文件名%,行数
REM If read is the last line, then exit
if "x"=="" goto 退出
REM Set the line number to add 1, that is, determine the next line to read next time
strings 行数=add %行数%,1
REM Check if there is a line with the string that needs to be modified in variable X
ECHO %X%|FIND /I "%字符串%">NUL
REM If not, then jump to the mark of writing the old file
if ERRORLEVEL 1 goto 写旧文件
:写新文件
REM There is a line in X with the string that needs to be modified, get the part of the string to be retained
STRINGS X=MID %X%,%取字符串数%
REM Write the retained string part and the part of the string to be added into the new file
ECHO %X%%新字符串%>>%新文件%
GOTO 11
:写旧文件
REM Write the old file line that does not need to be modified into the new file
ECHO %X%>>%新文件%
GOTO 11
:退出
REM Clear all variables
for %%x in (X 字符串 新字符串 文件名 新文件 取字符串数 行数) do SET %%x=>NUL
CLS
ECHO Work has been completed, please accept!
Last edited by 0451lym on 2007-2-17 at 08:05 AM ]
|
|
2007-2-17 08:02 |
|
|
grizzlyjian
新手上路

积分 12
发帖 6
注册 2007-2-17
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
对啊?我一点都不会,第一次发帖,开始学习了
Yeah? I don't know anything at all. It's my first post, and I'm starting to learn.
|
|
2007-2-17 08:49 |
|
|
米娜
初级用户
 
积分 147
发帖 20
注册 2003-1-11
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
5555 5555 5555 :(:( 0451lym 大叔 不对呀~~~
进入了一个死循环,且出现的 新文件.TXT 的内容是:
ECHO 处于关闭状态。
ECHO 处于关闭状态。
ECHO 处于关闭状态。
ECHO 处于关闭状态。
……
下边的附件就是那文件,麻烦大师测试一下~~~~ 俺笨~~~~ 有劳您了~~~~~ :( :(
Last edited by 米娜 on 2007-2-17 at 04:23 PM ]
5555 5555 5555 :(:( 0451lym Uncle, something's wrong~~~
Entered an infinite loop, and the content of the newly created file.TXT is:
ECHO is in a closed state.
ECHO is in a closed state.
ECHO is in a closed state.
ECHO is in a closed state.
……
The attached file below is that file. Please trouble the master to test it~~~~ I'm stupid~~~~ Thanks a lot~~~~ :( :(
Last edited by 米娜 on 2007-2-17 at 04:23 PM ]
附件
1: theme_descriptor.rar (2007-2-17 14:18, 528 bytes, 下载附件所需积分 1 点
,下载次数: 5)
|
|
2007-2-17 14:00 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
笨丫头想不出问题 系列主题~~~
Silly girl can't think of a problem Series theme~~~~
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2007-2-18 07:13 |
|
|
米娜
初级用户
 
积分 147
发帖 20
注册 2003-1-11
状态 离线
|
|
2007-2-19 15:45 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
sed -r "/^[ ]*grid_menu_bg=\x22xin([0-9]{3})\.jpg\x22[ ]*\/>[ ]*$/!d;s/\/>/idle_status_area_bg=\x22spacer.png\x22 idle_softkey_area_bg=\x22spacer.png\x22 &/" life
只适合这个
sed -r "/^*grid_menu_bg=\x22xin({3})\.jpg\x22*\/>*$/!d;s/\/>/idle_status_area_bg=\x22spacer.png\x22 idle_softkey_area_bg=\x22spacer.png\x22 &/" life
Only suitable for this
|
|
2007-2-23 01:40 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
如果用3方建议用UE~去编辑下~用正则表达式很快的。。。
If using a third party, it is recommended to use UE to edit. Using regular expressions is very fast...
|
|
2007-2-23 08:28 |
|