![]() |
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-09-28 12:19 |
47,813 topics / 349,918 posts / today 0 new / 48,277 members |
| DOS批处理 & 脚本技术(批处理室) » Batch convert BAT format files to TXT format (please optimize) |
| Printable Version 4,121 / 20 |
| Floor16 HAT | Posted 2008-05-19 17:40 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Directly using `ren` cannot meet the LZ's needs.
The methods of the friends on the 2nd and 3rd floors are not applicable when written into a batch file, because it will even change its own suffix |
|
| Floor17 gahoo | Posted 2008-05-19 18:17 |
| 初级用户 Posts 19 Credits 45 | |
|
Note that this later changed the current path. Please look carefully at "CD %1". If this batch file is not placed in the target directory, it will not be changed.
Please test the code first. Save as a batch file, then drag the folder where the batch file to be batch renamed is located onto this batch file, so as to solve the problem that you yourself are also changed to txt. However, I also found a problem. CD only changes the path, not the drive letter. Folders on non-C drives still don't work. Change it to pushd. [ Last edited by gahoo on 2008-5-19 at 06:31 PM ] |
|
| Floor18 HAT | Posted 2008-05-19 18:56 |
| 版主 Posts 5,017 Credits 9,023 | |
|
What the original poster intended was to process in the current directory. Does using cd go against the original poster's intention?
|
|
| Floor19 gahoo | Posted 2008-05-19 21:43 |
| 初级用户 Posts 19 Credits 45 | |
|
Well, that makes sense. I didn't read the requirements carefully. If it's the current directory, I have to copy the batch file back and forth, which is quite troublesome. Isn't it better to directly process the files in the target directory?
|
|
| Floor20 Batain | Posted 2008-05-25 09:50 |
| 初级用户 Posts 11 Credits 24 | |
|
Thanks. Generally, the files that need to be converted are placed in the same directory, so it's not troublesome to copy them one or two times. As long as it works, in short, all your methods are okay. This post has solved the problem for me personally. However, I still look forward to better methods appearing. I also look forward to some expert posting to share more creative methods in the future. Hehe~ Thank you all.
|
|
| Floor21 chinaname | Posted 2008-06-02 01:17 |
| 新手上路 Posts 4 Credits 10 | |
|
I found that the original poster is too sour. A simple REN command can handle it, and you still need to use BAT. You complicated a simple thing. The code you made is also complicated and too slow. It can clearly be done in a few lines.
@echo ren *.bat *.txt>>d:\t.bat @echo ren 1.txt *.bat>>d:\t.bat @echo del d:\t.bat>>d:\t.bat d:\t.bat |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |