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-06 08:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] An advanced question: replacing text strings View 1,691 Replies 20
Original Poster Posted 2007-10-31 13:00 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Floor 2 Posted 2007-10-31 13:26 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Floor 3 Posted 2007-10-31 13:31 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Sorry, brother,
what kind of command is this sed thing at the beginning?
I'm a Windows XP user, other than batch files I can understand,
how exactly do I run the command you provided?
Thanks
Floor 4 Posted 2007-10-31 13:32 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
sed is a third-party tool, a Unix tool, but there is a DOS version of it.

You can search the forum.
Floor 5 Posted 2007-10-31 13:41 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Please tell me, I found these two versions here, and I also want to learn the language for this set of tools.
http://tw.myblog.yahoo.com/c9993/article?mid=37&prev=73&next=20


Extracted path UnxUtils\usr\local\wbin

Extracted path UnxUpdates

What is the difference between these two?
And is it also like CGI or PHP environment variables?
Floor 6 Posted 2007-10-31 13:45 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Originally posted by leo1984 at 2007-10-31 01:41 PM:
Please tell me, I found these two versions here, and I also want to learn the language for this set of tools.
http://tw.myblog.yahoo.com/c9993/article?mid=37&prev=73&next=20


Extracted path UnxUtils\usr\l ...


Try this one, just put it under system32.
There are also some posts in the forum about simple sed usage.
Attachments
sed.rar (40.33 KiB, Downloads: 17)
Floor 7 Posted 2007-10-31 14:09 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Interesting tool.
Quite a few very handy commands.
Thanks for the guidance, brother ^^
Floor 8 Posted 2007-10-31 14:12 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
I forgot to ask, brother,
I have a lot of text files to process.
The command you gave can only process one file at a time.
How do I process the text files in the whole directory and then output them?
Thanks
Floor 9 Posted 2007-10-31 14:15 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Use a for %%i in (.cgi)
Floor 10 Posted 2007-10-31 14:19 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Write it like this? @@
Doesn't seem to work.

@echo off
md Temp
for /f "delims=" %%f in ('dir /on/b "*.txt"') do (
echo.>Temp\%%~nf.txt
sed "s#^\(*\)∥\(*\)\(.*\)#\2∥\1\3#" %%i in (%%f) do sed %%i∥%%j∥%%k∥%%l∥%%m∥%%n∥%%o∥>>Temp\%%~nf.txt
)
pause

[ Last edited by leo1984 on 2007-10-31 at 02:20 PM ]
Floor 11 Posted 2007-10-31 14:25 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
Figure it out yourself, I didn't say it should be written like this
Floor 12 Posted 2007-10-31 15:07 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
Sorry to trouble you, brother.
I've been studying it for quite a while, and what I wrote still can't succeed smoothly.
Please first guide this newbie on how to write it.
Help me get my website text processed first, many thanks ><
Floor 13 Posted 2007-10-31 15:13 ·  中国 浙江 衢州 中移铁通
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
@echo off
md Temp
for %%i in (*.txt) do (
echo.>Temp\%%~nxi
sed "s#^\(*\)∥\(*\)\(.*\)#\2∥\1\3#" "%%~nxi">>Temp\%%~nxi
)


Modified based on what the OP posted.

Haven't tested it.
pause
Floor 14 Posted 2007-10-31 16:01 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
The one I gave you before would work already, just swap %%i and %%j

@echo off
md Temp
for /f "delims=" %%f in ('dir /on/b "*.txt"') do (
echo.>Temp\%%~nfNew.txt
for /f "tokens=1,2,3,4 delims=∥" %%i in (%%f) do echo %%j∥%%i∥%%k∥%%l∥>>Temp\%%~nfNew.txt
)
pause
Floor 15 Posted 2007-10-31 18:49 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 96
Posts 43
Joined 2007-10-31 01:20
18-year member
UID 101245
Gender Male
Status Offline
The brothers above are all really enthusiastic, the test works fine now.
I also do Chinese localization and cracking software myself.
Being able to learn together with you brothers is really great.
Once the website is fixed, I'll come exchange and learn with all of you experts too ^^
Forum Jump: