![]() |
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-25 23:45 |
47,812 topics / 349,910 posts / today 0 new / 48,264 members |
| DOS批处理 & 脚本技术(批处理室) » How to copy specified content into a specified file |
| Printable Version 4,071 / 7 |
| Floor1 namejm | Posted 2006-03-31 21:55 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Under Windows XP, if you want to copy all the text content after the third line of 1.txt to a specified text file, how can you achieve it?
|
|
| Floor2 3742668 | Posted 2006-04-01 07:50 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
```
for /f "skip=3 tokens=*" %%i in (1.txt) do @echo %%i >>指定文件.txt ``` |
|
| Floor3 namejm | Posted 2006-04-01 12:59 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Then how to get only a few lines? For example, if a text file has 100 lines, and now we only need lines 20 - 25 and the content after line 30, how to write it?
In addition, if you want the format of the extracted file content to be consistent with the original file format, for example, there are blank lines between lines 35 to 40, and the first line of lines with text all have spaces, how to achieve it? [ Last edited by namejm on 2006-4-1 at 13:14 ] |
|
| Floor4 chenhui530 | Posted 2006-04-01 16:50 |
| 高级用户 Posts 273 Credits 772 | |
|
It should be quite complicated to implement with batch processing, while it's much simpler with VBS.
|
|
| Floor5 Climbing | Posted 2006-04-01 19:07 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Try Horst's Lmod program.
|
|
| Floor6 无奈何 | Posted 2006-04-02 00:55 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
You can try to solve it with sed
Sed download address: http://www.student.northpark.edu/pemente/sed/gsed407x.zip |
|
| Floor7 namejm | Posted 2006-04-02 12:44 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Is it very complicated to achieve only through DOS batch processing without relying on third-party software?
|
|
| Floor8 3742668 | Posted 2006-04-02 12:45 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Agree with the 4th floor.
Save it as "File Processing.vbs" and then double-click to run, which can roughly meet your requirements. Of course, you can also write the code into a vbs file in the batch processing to achieve the effect of batch processing. In that case, you can remove the previous dialog box part and add parameters. Oh, I should have used adodb, but I forgot. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |