中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 01:40
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] Text content checking, replacement, and insertion
Printable Version  1,024 / 4
Floor1 NEXT Posted 2010-09-21 00:02
新手上路 Posts 8 Credits 14
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 ]
Floor2 NEXT Posted 2010-09-21 00:13
新手上路 Posts 8 Credits 14
I looked through the collection threads from 2007 and 2008, but still can't make it work :(
Floor3 tongzj Posted 2010-09-21 14:00
初级用户 Posts 43 Credits 49
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
Floor4 tongzj Posted 2010-09-21 14:01
初级用户 Posts 43 Credits 49
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
Floor5 NEXT Posted 2010-09-22 13:25
新手上路 Posts 8 Credits 14
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.


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 ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023