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-06-29 13:03
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to use the COPY command to merge multiple files into one continuous file? View 1,549 Replies 5
Original Poster Posted 2005-12-05 09:46 ·  中国 广东 肇庆 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
Operating environment: Win XP CMD (ver 5.1.2600). Due to work needs, I now need to read a local log file in a batch file and convert the log into a VBS display. (The content stored in the log is only a text file, and there are no VBS statements.)

So I must add "(MSGbox ") at the front of the log and (") at the back, then change it to a script with the.vbs suffix and execute it.

The problem is that there are some small problems when operating with the following code in the batch file:

copy xxx.log 2.txt
echo MSGbox ">1.txt
echo ",64,"日志明细">3.txt
copy 1.txt+2.txt+3.txt 4.vbs
start 4.vbs


After execution, there will be an extra carriage return after MSGbox " in the generated vbs file. You know that carriage returns are not allowed in.vbs. Please ask the experts in the forum for guidance.

I found that when using echo MSGbox ">1.txt, an extra blank line will be added at the end of 1.txt. I think the problem is here. Can I delete the carriage return in the echo input?

[ Last edited by voiL on 2005-12-5 at 09:48 ]
Floor 2 Posted 2005-12-05 13:29 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
Using ECHO will automatically add carriage returns and line feeds. To remove them, you can use DEBUG:

Method:
For example, generate 1.txt:

echo abc>1.txt

rem Write the DEBUG script script: (remove carriage returns and line feeds, actually just remove the last two bytes 0D, 0A)
echo n 1.txt > script
echo l >>script
echo rcx >>script
echo 3 >>script
echo w >>script
echo q >>script

rem Run DEBUG:
debug < script

But you need to calculate the bytes well. If there are multiple lines, it will be more troublesome.

[ Last edited by GOTOmsdos on 2005-12-5 at 13:37 ]
Floor 3 Posted 2005-12-05 16:04 ·  中国 广东 肇庆 四会市 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
Thanks to brother GOTOmsdos, I have tried your method. When it exceeds 3 bytes, it will only delete the following ones.

It is not very easy to control when modifying.

Because my log file is also written in with echo, so the size will keep increasing.

[ Last edited by voiL on 2005-12-5 at 17:41 ]
Floor 4 Posted 2005-12-05 18:57 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
It seems that it still needs to be solved by writing a program.. Just write a simple C console program.. Then a batch script, put it in the task scheduler..
Floor 5 Posted 2005-12-05 19:06 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re voiL:

Consider using the inline assembly in Debug to subtract 2 from the cx value. If the log file exceeds 64K, you need to take both bx and cx values into account. Of course, this method is still relatively clumsy. You can consider using a string replacement tool to replace 0d 0a in the log file with empty, or use other VBS functions that can handle text with carriage returns.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2005-12-06 12:06 ·  中国 辽宁 锦州 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
If you can use a third - party tool, it's very simple.

The following is the solution using SED:


sed -e "1s/^/MSGbox\"/" -e "$s/$/\",64,\"Log Details\"/" xxx.log>4.vbs
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Forum Jump: