What should be paid attention to when using wildcard in Ren command

Time:2021-2-26

1、
Ren full file name * specifies any character or continuous string in the full file name. Extension
Change the file name to: from the beginning of the original file name to the specified character (string). Extension
For example:
10. C for Ren 10. PDF * 0. C
Ren 10. PDF * P.C gets 10. P.C
Ren 10. PDF * D.C is 10. PD. C

2、
Ren full file name * specifies a non contiguous string of full file names. Extension
Change the file name to: from the beginning of the original file name to the first character of the specified string + the remaining string content. Extension
For example:
Ren 10. PDF * 1p. C get 1p. C
Ren 10. PDF * 0dp. C get 10dp. C

3、
Ren full file name * specifies any character (string) except the full file name. Extension
Change the file name to: general configuration full file name + specified character (string). Extension
as
Ren 10. PDF * mm. C is 10. Pdfmm. C

Originally posted by bjsh at 2007-4-13 10:10 PM:
Create a new 10. PDF in disk C
Carry out the following two commands;
Let’s see what the last 10. PDF was renamed/

ren 10.pdf *2.c
The results were: 10. Pdf2. C

ren 10.pdf *1.c
The result was 1. C

ren 10.pdf *2.c

*What’s the first word after that?
2
10. Is this word in PDF?
No. So, it’s in the back
10.pdf
2.c

10.pdf2.c

ren 10.pdf *1.c

*What’s the first word after that?
1

10. Is this word in PDF?
yes. Look from the back. The first one you find is aligned

10. PDF 1 delete later
1. C 1 later
1.c

ren 10010.pdf *1.c

*What’s the first word after that?
1

Is this word in 10010.pdf?
yes. Look from the back. The first one you find is aligned

10010.pdf 1 delete later
1. C 1 later
1001.c

Special cases
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”