How can I rename subfolder

November 27, 2010 at 18:18:18
Specs: Windows 7
I would like to rename my subfolder all at once. Like search and rename. But rename just the subfolder.

Example:
I have lots of folders with different name. But in each folder I have a subfolder with a same name.
From:
C;\data\project\question
C:\data\goal\question
C:\data\request\question
C:\data\invite\question
C:\data\meeting\question

To:
C;\data\project\answer
C:\data\goal\answer
C:\data\request\answer
C:\data\invite\answer
C:\data\meeting\answer

Please help. Thanks.


See More: How can I rename subfolder

Report •


#1
November 28, 2010 at 07:11:23
@echo off & setLocal EnableDELAYedeXpansion

pushd C:\data

for /f "tokens=* delims= " %%a in ('dir/b/s/ad question') do (
ren %%a answer
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
November 28, 2010 at 09:34:36
Thank you for your quick respone. I got the error message the syntax of the command is incorrect or invalid. Could you double check the script below please. Thanks again!

@echo off
setLocal EnableDELAYedeXpansion

pushd F:\Parish Data

for /f "tokens=* delims= " %%a in ('dir/b/s/ad test') do (
ren %%a test1
)


Report •

#3
November 28, 2010 at 09:57:17
The paths you listed have no spaces. This one does.


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
November 28, 2010 at 11:28:40
Thanks. So how do I fix it when my path has a space? Thank you for your time.

For example:
F:\Parish Data\02-044 St Mary (20)\Question
F:\Parish Data\04-076 St Joseph (42)\Question
F:\Parish Data\05-012 St Charles (35)\Question

Rename to this:
F:\Parish Data\02-044 St Mary (20)\Answer
F:\Parish Data\04-076 St Joseph (42)\Answer
F:\Parish Data\05-012 St Charles (35)\Answer


Report •

#5
November 28, 2010 at 11:45:18
@echo off
setLocal EnableDELAYedeXpansion

pushd "F:\Parish Data"

for /f "tokens=* delims= " %%a in ('dir/b/s/ad test') do (
ren "%%a" test1
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#6
November 28, 2010 at 13:05:12
You're good. It works. Thank you so much. Do you have time for one more?

I want to create a new folder and somehow copy it to all the subfolders in F:\Parish Data.

For example:
I create a folder in F:\Parish Data: Current Year Invoice
I would like to copy this to more than 100 subdirectories:
F:\Parish Data\02-044 St Mary (20)\Current Year Invoice
F:\Parish Data\04-076 St Joseph (42)\Current Year Invoice
F:\Parish Data\05-012 St Charles (35)\Current Year Invoice
and so on...

Could you help me?


Report •

#7
November 28, 2010 at 13:55:39
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/ad "F:\Parish Data"') do (
md "%%a\Current Year Invoice"
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#8
November 28, 2010 at 18:13:41
Thank you. You're outstanding... it works like a charm. Even with more than 100 folders. Have a good evening!

Report •


Ask Question