Page 1 of 1

Batch rename a whole series of folders

Posted: 11 Sep 2009 04:40
by leysfi
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?

Posted: 11 Sep 2009 09:46
by avery_larry
**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%%"
)