Adding Serial Number while rename files through MS-Dos

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Asim
Posts: 2
Joined: 02 Dec 2021 23:18

Adding Serial Number while rename files through MS-Dos

#1 Post by Asim » 02 Dec 2021 23:39

Respected All!
A folder contained 45 files and I want to rename all these files by adding serial number in the start of each file like

1. BirthDayShots
2. BirthDayShots
3. BirthDayShots
.
.
.
.
.
45. BirthDayShots

Looking forward

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: Adding Serial Number while rename files through MS-Dos

#2 Post by AR Coding » 03 Dec 2021 08:41

Is this what you mean?

Code: Select all

Setlocal EnableDelayedExpansion 
set i=0
set "filepath=C:\Folder\of\files"
for /R %filepath% %%a in (*.*) do (
 set /a i+=1
 ren "%%~dpnxa" "!i!. %%~nxa"
)

Asim
Posts: 2
Joined: 02 Dec 2021 23:18

Re: Adding Serial Number while rename files through MS-Dos

#3 Post by Asim » 06 Dec 2021 01:10

Thank You! Serial Number added successfully but I also want to change file(s) names as well

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: Adding Serial Number while rename files through MS-Dos

#4 Post by AR Coding » 06 Dec 2021 17:09

to what?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Adding Serial Number while rename files through MS-Dos

#5 Post by Squashman » 06 Dec 2021 20:57

Asim,
Your technical specifications for what you wanted to accomplish was extremely lacking. If I was given this little information I would be giving this back to my business analysts to rewrite it. Please be more specific with what you want to accomplish. Provide complete input and output examples.

Post Reply