Batch rename a whole series of folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
leysfi
Posts: 1
Joined: 11 Sep 2009 04:09

Batch rename a whole series of folders

#1 Post by leysfi » 11 Sep 2009 04:40

I have several hundreds of folders, named ABCDxxxx (xxxx being a distinct number for each folder), all depending from the same mother directory, and I would like to convert them to WXYZxxxx (xxxx being the same number the original folder had). Is there any DOS or batch way of doing this?

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 11 Sep 2009 09:46

**UNTESTED**

Code: Select all

@echo off
set "parentdir=c:\tmp"

cd /d "%parentdir%"
for /d %%a in (ABCD*) do (
   set "currentdir=%%~a"
   call move "%%~a" "WXYZ%%currentdir:~4,9999%%"
)

Post Reply