![]() |
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-08 22:26 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » How to add a carriage return character after a fixed-length string in a text file |
| Printable Version 1,718 / 7 |
| Floor1 ntsznc | Posted 2007-07-02 17:01 |
| 初级用户 Posts 15 Credits 33 | |
|
The text file is as follows:
All data is only one line, so I want to add a carriage return after the fixed - length string Mon Jul 03 06:23:05 2007,JQ059,Mon Jul 04 05:59:58 2007,EJ101,Mon Jul 02 05:57:24 2007,JQ059,Mon Jul 02 05:50:37 2007,EJ095,Mon Jul 02 05:40:05 2007,EJ101,Mon Jul 02 05:27:13 2007,JJ003,Mon Jul 02 05:21:34 2007,ET299,Mon Jul 02 04:13:41 2007,JR021,Mon Jul 02 03:22:20 2007,JQ059,Mon Jul 02 03:08:58 2007,JQ059,Mon Jul 02 02:51:58 2007,JQ059,Mon Jul 02 02:32:42 2007,JQ059,Mon Jul 02 02:07:11 2007,EZ058,Mon Jul 02 02:07:11 2007,EZ057,Mon Jul 02 02:05:00 2007,EC023,Mon Jul 02 01:46:27 2007,ES396,Mon Jul 02 01:46:27 2007,ES394,Mon Jul 02 01:45:00 2007,JR021,Mon Jul 02 01:43:59 2007,JR022,Mon Jul 02 01:41:40 2007,ES396,Mon Jul 02 01:41:40 2007,ES395,Mon Jul 02 01:41:40 2007,ES394,Mon Jul 02 01:41:01 2007,JR022,Mon Jul 02 01:40:14 2007,JR022,Mon Jul 02 01:38:38 2007,ER150,Mon Jul 02 01:37:50 2007,JR056,Mon Jul 02 01:36:36 2007,ER150,Mon Jul 02 01:35:41 2007,ER150,Mon Jul 02 01:31:01 2007,ER150,Mon Jul 02 01:29:12 2007,ER150,Mon Jul 02 01:28:34 2007,ER150,Mon Jul 02 01:27:58 2007,JR021,Mon Jul 02 01:27:08 2007,JR020,Mon Jul 02 01:27:08 2007,JR019,Mon Jul 02 01:26:18 2007,JR022,Mon Jul 02 01:26:18 2007,JR021,Mon Jul 02 01:26:18 2007,JR019,Mon Jul 02 01:25:23 2007,JR022,Mon Jul 02 01:25:23 2007,JR021,Mon Jul 02 01:25:23 2007,JR020,Mon Jul 02 01:25:23 2007,JR019,Mon Jul 02 00:52:21 2007,CZ164,Mon Jul 02 00:51:27 2007,NZ096,Mon Jul 02 00:43:13 2007,WZ131,Mon Jul 02 00:40:01 2007,NZ096,Mon Jul 02 00:08:14 2007,CZ164,Sun Jul 01 23:42:40 2007,CZ164,Sun Jul 01 23:41:23 2007,CZ164,Sun Jul 01 23:27:48 2007,CZ164,Sun Jul 01 23:24:14 2007,CZ164,Sun Jul 01 23:22:51 2007,CZ164,Sun Jul 01 23:20:17 2007,CZ164,Sun Jul 01 22:47:28 2007,JR020,Sun Jul 01 22:45:59 2007,EQ151,Sun Jul 01 22:45:59 2007,EQ149,Sun Jul 01 22:45:57 2007,JR022,Sun Jul 01 22:45:57 2007,JR021,Sun Jul 01 22:45:57 2007,JR020,Sun Jul 01 22:45:57 2007,JR019,Sun Jul 01 21:10:31 2007,JR020,Sun Jul 01 21:09:05 2007,JR020,Sun Jul 01 20:49:18 2007,JR020,Sun Jul 01 20:41:31 2007,JR020,Sun Jul 01 20:34:56 2007,JR020,Sun Jul 01 20:33:39 2007,JR020,Sun Jul 01 20:32:16 2007,JR020,Sun Jul 01 20:20:51 2007,JR057,Sun Jul 01 20:18:07 2007,JR057,Sun Jul 01 20:13:40 2007,ET299,Sun Jul 01 20:11:27 2007,ET299, Please help Thank you |
|
| Floor2 lxmxn | Posted 2007-07-03 07:55 |
| 版主 Posts 4,938 Credits 11,386 | |
|
The following is an example, and you can modify it freely:
AddReturn.txt is the text you want to process. sed is an external tool. Download address: http://www.cn-dos.net/forum/viewthread.php?tid=30573&page=2#pid201020 |
|
| Floor3 ntsznc | Posted 2007-07-03 11:26 |
| 初级用户 Posts 15 Credits 33 | |
|
Thanks. Already tested and OK.
|
|
| Floor4 flyingphf | Posted 2008-03-26 19:47 |
| 中级用户 Posts 142 Credits 392 | |
|
Under DOS, it wraps lines. I want to ask why there's no line break when saving, and only a black square is displayed.
|
|
| Floor5 ThinKing | Posted 2008-03-27 01:10 |
| 中级用户 Posts 207 Credits 471 | |
Originally posted by flyingphf at 2008-3-26 07:47 PM: Adding a " | more > newfile.txt " after the command will do the trick. |
|
| Floor6 zhengruijian | Posted 2008-06-01 06:46 |
| 初级用户 Posts 24 Credits 54 | |
|
Please input the范文 content so that I can continue with the translation and related processing instructions.
|
|
| Floor7 zhengruijian | Posted 2008-06-01 06:46 |
| 初级用户 Posts 24 Credits 54 | |
|
8、 I Apologize.
我很抱歉。 A: Jessie, I’m afraid I can’t come back home for dinner tonight. 杰茜,我恐怕今晚不能回家吃晚饭了。 B: Not back home for dinner again? That’s the third time this week! 又不回家吃晚饭?这个星期你已经是第三次了这样了! A: I’m sorry. Our company has just opened. There are always too many things to handle. You know that. 对不起。我们的公司刚刚开业,总是有太多事情要处理,这你是知道的。 B: You don’t have to explain. Suit yourself. 你不必解释了。随便你。 A: I apologize. You have my word, I’ll spend some time with you on the weekend. I promise. 很抱歉。我向你保证,周末抽时间来陪你。我发誓。 B: We’ll see. 再说吧。 A: Thank you for understanding. I promise I’ll make it up to you. 谢谢你能理解。我保证一定给你补上。 A: Sam, you’ve got to forgive me. 山姆,你得原谅我。 B: Forgive you for what? 原谅你什么? A: I used your computer. And I’m afraid I’ve erased your personal files accidentally. 我用了你的电脑。恐怕我不小心把你的私人文件删掉了。 B: No! Are you kidding me? 不!你跟我开玩笑? A: I’m afraid not. I apologize. 不是。我很抱歉。 B: I can’t believe it! I have all my important personal documents stored in that computer. It’s no laughing matter. 我简直不敢相信!我将所有重要的私人资料都存入电脑了。这可不是闹着玩的。 A: I told you I’m sorry. What can I do to make it up to you? 我都跟你道歉了。我怎样做才能弥补我的过错? B: Well, you should be sorry! Don’t ever use my computer again! You can’t do anything now, it’s too late! 你应该道歉!再也不许用我的电脑了!现在你做什么都没有用了,已经太迟了! |
|
| Floor8 zhengruijian | Posted 2008-06-01 08:31 |
| 初级用户 Posts 24 Credits 54 | |
|
@echo off
for /f "delims=" %%a in (yourtext.txt) do ( set var=%%a setlocal enabledelayedexpansion set var=!var: =! if not "!var!"=="" set var=!var: =! if not "!var!"=="" echo !var! endlocal ) pause This program is correct, but it cannot be saved |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |