China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-21 12:01
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question: batch rename "*.exe" to "*.ex" View 4,598 Replies 10
Original Poster Posted 2007-01-14 09:38 ·  中国 广西 南宁 西乡塘区 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-18 22:10
19-year member
UID 73879
Gender Male
Status Offline
: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
Floor 2 Posted 2007-01-14 10:02 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 3 Posted 2007-01-14 10:09 ·  中国 广西 南宁 西乡塘区 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-18 22:10
19-year member
UID 73879
Gender Male
Status Offline
What I mean is all exe files on drive D. Including those in subfolders.
Floor 4 Posted 2007-01-14 10:13 ·  中国 广东 广州 电信
高级用户
★★★
潜水修练批处理
Credits 788
Posts 366
Joined 2006-12-31 02:43
19-year member
UID 75048
Gender Male
Status Offline
Floor 5 Posted 2007-01-14 10:32 ·  中国 广西 南宁 西乡塘区 电信
新手上路
Credits 16
Posts 6
Joined 2006-12-18 22:10
19-year member
UID 73879
Gender Male
Status Offline
Thanks. Thanks to the friend in post #4. Also thanks to the friend in post #2.
Floor 6 Posted 2007-01-14 11:23 ·  中国 陕西 汉中 电信
初级用户
Credits 136
Posts 49
Joined 2007-01-04 08:28
19-year member
UID 75413
Gender Male
Status Offline
%%~ni
I just started learning DOS and want to ask what this means! I can't understand this line!
Floor 7 Posted 2007-01-14 11:29 ·  中国 广东 广州 白云区 电信
中级用户
★★
Credits 251
Posts 108
Joined 2007-01-07 11:33
19-year member
UID 75721
Gender Male
From 湖南==>广州
Status Offline
Expand variable i to the file name..
Floor 8 Posted 2007-01-15 10:15 ·  中国 河南 洛阳 联通
新手上路
Credits 11
Posts 6
Joined 2007-01-15 08:42
19-year member
UID 76568
Gender Male
Status Offline
Is there such an extension?
Floor 9 Posted 2007-01-15 10:39 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
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 ]
Floor 10 Posted 2007-03-25 06:56 ·  中国 河南 郑州 教育网
新手上路
Credits 6
Posts 2
Joined 2007-03-20 20:57
19-year member
UID 82376
Gender Female
Status Offline
Friend in post #9, your method still doesn't work. I tried it.
Floor 11 Posted 2007-06-04 15:14 ·  中国 重庆 大足区 联通
初级用户
Credits 44
Posts 25
Joined 2007-03-25 00:24
19-year member
UID 82812
Gender Male
Status Offline
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 %%
Forum Jump: