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-27 15:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Is this a bug of ren? View 7,927 Replies 18
Floor 16 Posted 2008-04-27 21:41 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
Credits 109
Posts 30
Joined 2007-09-05 14:27
18-year member
UID 96621
Gender Male
Status Offline
Originally posted by bjsh at 2007-4-13 10:10 PM:
Create a 10.pdf in the C drive.

Execute the following two commands;

See what 10.pdf is renamed to in the end/

ren 10.pdf *2.c
The result is: 10.pdf2.c

ren 10.pdf *1.c
The result is 1.c




ren 10.pdf *2.c

What is the first character after *?
2

Is there this character in 10.pdf?
No. So, it is appended at the end

10.pdf
2.c

10.pdf2.c





ren 10.pdf *1.c

What is the first character after *?
1

Is there this character in 10.pdf?
Yes. Find the first one from the end, and align

10.pdf Delete after 1
1.c Append after 1
1.c



ren 10010.pdf *1.c

What is the first character after *?
1

Is there this character in 10010.pdf?
Yes. Find the first one from the end, and align

10010.pdf Delete after 1
1.c Append after 1
1001.c





Special case ren * *.
ren * "* "


FAT32

C:\TEST>cd.>123...456...789.mp3

C:\TEST>dir/b
123...456...789.mp3

C:\TEST>ren * *.

C:\TEST>dir/b
123...456...789

C:\TEST>ren * *.

C:\TEST>dir/b
123

---
C:\TEST>cd.>"123 456 789.mp3"

C:\TEST>dir/b
123 456 789.mp3

C:\TEST>ren * "* "

C:\TEST>dir/b
123

C:\TEST>for %a in (*) do @echo "%a"
"123"



NTFS

D:\TEST>cd.>123...456...789.mp3

D:\TEST>dir/b
123...456...789.mp3

D:\TEST>ren * *.

D:\TEST>dir/b
123...456...789

D:\TEST>ren * *.

D:\TEST>dir/b
123...456

D:\TEST>ren * *.

D:\TEST>dir/b
123

---
D:\TEST>cd.>"123 456 789.mp3"

D:\TEST>dir/b
123 456 789.mp3

D:\TEST>ren * "* "

D:\TEST>dir/b
123 456

D:\TEST>for %a in (*) do @echo "%a"
"123 456"

D:\TEST>ren * "* "

D:\TEST>dir/b
123

D:\TEST>for %a in (*) do @echo "%a"
"123"


[ Last edited by mkd on 2008-4-28 at 05:42 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
gool123456 +1 2010-05-01 20:24
Floor 17 Posted 2009-12-04 20:28 ·  中国 福建 莆田 电信
新手上路
Credits 1
Posts 1
Joined 2009-12-03 21:56
16-year member
UID 155878
Gender Male
Status Offline
What a wonderful thing!
Floor 18 Posted 2009-12-06 14:06 ·  中国 湖北 武汉 教育网
新手上路
Credits 12
Posts 11
Joined 2009-11-28 17:39
16-year member
UID 155545
Gender Male
Status Offline
Floor 19 Posted 2010-03-25 16:29
新手上路
Credits 7
Posts 4
Joined 2010-03-15 14:52
16-year member
UID 162232
Gender Male
Status Offline
Forum Jump: