China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 02:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Text content checking, replacement, and insertion View 1,026 Replies 4
Original Poster Posted 2010-09-21 00:02 ·  中国 广东 揭阳 电信
新手上路
Credits 14
Posts 8
Joined 2007-01-09 04:17
19-year member
UID 75907
Gender Male
Status Offline
Suppose there is an .ini file called forTest.ini, with contents roughly like this:
----------------------------------------------------------

aaaText=a content a content a content a content
bbbText=b content b content b content b content
......
----------------------------------------------------------
Here, the content of “a content a content a content a content” is variable

What I want to do:
1. First, “Set /p input=Please enter content:”
2. First check whether the file contains the line “aaaText=...”
3. If it exists, then change the content after “aaaText=” to “%input%
4. If it does not exist, then insert “aaaText=%input%” on the line after “”

[ Last edited by NEXT on 2010-9-22 at 14:28 ]
Floor 2 Posted 2010-09-21 00:13 ·  中国 广东 揭阳 电信
新手上路
Credits 14
Posts 8
Joined 2007-01-09 04:17
19-year member
UID 75907
Gender Male
Status Offline
I looked through the collection threads from 2007 and 2008, but still can't make it work :(
Floor 3 Posted 2010-09-21 14:00 ·  中国 北京 联通
初级用户
Credits 49
Posts 43
Joined 2007-01-20 03:28
19-year member
UID 77088
Gender Male
Status Offline
Your approach is not very good. If you have to handle a very large file, or if the file contains special characters, you have to take those into account. I recommend using inifile.exe; this program is specifically for editing ini files.
Official link: http://home.mnet-online.de/horst.muc/wbat32.htm#inifile
Floor 4 Posted 2010-09-21 14:01 ·  中国 北京 联通
初级用户
Credits 49
Posts 43
Joined 2007-01-20 03:28
19-year member
UID 77088
Gender Male
Status Offline
Your approach is not very good. If you have to handle a very large file, or if the file contains special characters, you have to take those into account. I recommend using inifile.exe; this program is specifically for editing ini files.
Official link: http://home.mnet-online.de/horst.muc/wbat32.htm#inifile
Floor 5 Posted 2010-09-22 13:25 ·  中国 广东 揭阳 电信
新手上路
Credits 14
Posts 8
Joined 2007-01-09 04:17
19-year member
UID 75907
Gender Male
Status Offline
The file is not large, it's just the “desktop.ini” file in a folder, and the content usually isn't much, right? Special characters do need to be considered though.


InfoTip=Haha, this is the folder description content...
IconResource=C:\Windows\system32\SHELL32.dll,4


Mode=
Vid=
FolderType=Generic


What I mainly want to do is add an “Add/Modify Description Info” item to the folder right-click menu, and after clicking it, directly enter the description content to be added or modified.

The effect would be roughly like my “folder disguise”:
http://www.brsbox.com/filebox/down/fc/159396c23f39271b26d58697056a8fc2

[ Last edited by NEXT on 2010-9-22 at 13:39 ]
Forum Jump: