Solved How to rename folders inside subfolders using batch file

September 9, 2020 at 10:30:50
Specs: Windows 10
Hi I need help with batch file.

I need to rename the folder and I was trying to write a batch file. I saw a few batch command and tried many times but nothing is working for me. I am very beginner to the batch scripting too.

I have folder as

System\0001\System Drawing
System\0002\System Drawing
System\0003\System Drawing
.
.
.
etc
and I want to rename as
System\0001\Drawing
System\0002\Drawing
System\0003\Drawing
.
.

How can I create a batch file to rename all the folders.

Thanks a lot,
Htet

message edited by Htet


See More: How to rename folders inside subfolders using batch file


#1
September 9, 2020 at 12:50:49
✔ Best Answer
Suppose your MainFolder is located at this path :"E:\test\System"
You can do something like this in batch script :

@echo off
Set MainFolder=E:\test\System

FOR /D %%D IN ("%MainFolder%\*") DO CALL :RENAME %%D
pause & exit

REM -------------------------------------------------------
:RENAME
SET CRITERIA=System Drawing
FOR /D %%R IN ("%1\%CRITERIA%") DO RENAME %%R "Drawing"
REM -------------------------------------------------------


Reply ↓  Report •

#2
September 10, 2020 at 05:25:00
Hi Hackoo,

Thank you so much. It is working.

Thanks a lot.

Htet

message edited by Htet


Reply ↓  Report •
Related Solutions


Ask Question