![]() |
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-17 16:54 |
47,814 topics / 349,907 posts / today 4 new / 48,259 members |
| DOS疑难解答 & 问题讨论 (解答室) » How to use the COPY command to merge multiple files into one continuous file? |
| Printable Version 1,599 / 5 |
| Floor1 voiL | Posted 2005-12-05 09:46 |
| 中级用户 Posts 189 Credits 384 | |
|
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:
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 ] |
|
| Floor2 GOTOmsdos | Posted 2005-12-05 13:29 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
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 ] |
|
| Floor3 voiL | Posted 2005-12-05 16:04 |
| 中级用户 Posts 189 Credits 384 | |
|
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 ] |
|
| Floor4 GOTOmsdos | Posted 2005-12-05 18:57 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
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..
|
|
| Floor5 willsort | Posted 2005-12-05 19:06 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
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. |
|
| Floor6 无奈何 | Posted 2005-12-06 12:06 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
If you can use a third - party tool, it's very simple.
The following is the solution using SED: |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |