中国DOS联盟论坛

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-29 08:05
47,816 topics / 349,916 posts / today 0 new / 48,265 members
DOS批处理 & 脚本技术(批处理室) » Question: batch rename "*.exe" to "*.ex"
Printable Version  4,742 / 10
Floor1 mf008 Posted 2007-01-14 09:38
新手上路 Posts 6 Credits 16
:o
How can I change all files in d: with the exe extension to files with the ex extension?

I'm a newbie, hope all you experts can give me some pointers. Thanks
Floor2 namejm Posted 2007-01-14 10:02
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Floor3 mf008 Posted 2007-01-14 10:09
新手上路 Posts 6 Credits 16
What I mean is all exe files on drive D. Including those in subfolders.
Floor4 dikex Posted 2007-01-14 10:13
高级用户 Posts 366 Credits 788
Floor5 mf008 Posted 2007-01-14 10:32
新手上路 Posts 6 Credits 16
Thanks. Thanks to the friend in post #4. Also thanks to the friend in post #2.
Floor6 beeny Posted 2007-01-14 11:23
初级用户 Posts 49 Credits 136
%%~ni
I just started learning DOS and want to ask what this means! I can't understand this line!
Floor7 Eblis Posted 2007-01-14 11:29
中级用户 Posts 108 Credits 251 From 湖南==>广州
Expand variable i to the file name..
Floor8 ytfsse Posted 2007-01-15 10:15
新手上路 Posts 6 Credits 11
Is there such an extension?
Floor9 GOTOmsdos Posted 2007-01-15 10:39
铂金会员 Posts 1,827 Credits 5,154
Unless absolutely necessary, it's best not to use things like delims and dir to parse screen output. First, the efficiency is relatively low; second, it's easy to make mistakes. The key to the OP's problem is just using the FOR /R parameter:
The following is enough: (actually, the use of delims and dir is unnecessary)
C:>for /r d: %a in (*.exe) do if exist %a rename %a %~na.ex

[ Last edited by GOTOmsdos on 2007-1-15 at 10:54 AM ]
Floor10 86763510 Posted 2007-03-25 06:56
新手上路 Posts 2 Credits 6
Friend in post #9, your method still doesn't work. I tried it.
Floor11 step2step Posted 2007-06-04 15:14
初级用户 Posts 25 Credits 44
Originally posted by 86763510 at 2007-3-25 06:56 AM:
Friend in post #9, your method still doesn't work. I tried it.

I tried it, it does work. If you use it in a batch file, you need to change % to %%
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023