Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:22:11+00:00 2026-05-31T05:22:11+00:00

I have read this post and I can’t meet my requirements. My Folder structure

  • 0

I have read this post and I can’t meet my requirements.

My Folder structure is:

_TEMPLATE_
|_ _TEMPLATE_SUBFOLDER1
|   |_ _TEMPLATE_SUB_SUBFOLDER1
|   |   |_ _TEMPLATE_FILE11.txt
|   |   |_ _TEMPLATE_FILE12.xml
|   |_ _TEMPLATE_SUB_SUBFOLDER2
|   |   |_ _TEMPLATE_FILE21.txt
|   |   |_ _TEMPLATE_FILE22.xml
|   |_ TEMPLATE_SUB_SUBFOLDER3
|_ _TEMPLATE_SUBFOLDER2
    |_TEMPLATE_FILE3.xml

I want to replace the _TEMPLATE_ to desired name
for ex. Stores so result will be

Stores
|_ StoresSUBFOLDER1
|   |_ StoresSUB_SUBFOLDER1
|   |   |_ StoresFILE11.txt
|   |   |_ StoresFILE12.xml
|   |_ StoresSUB_SUBFOLDER2
|   |   |_ StoresFILE21.txt
|   |   |_ StoresFILE22.xml
|   |_ StoresSUB_SUBFOLDER3
|_ StoresSUBFOLDER2
    |StoresFILE3.xml

I searched web there is option to traverse only files. and none of them go recursive rename
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:22:11+00:00Added an answer on May 31, 2026 at 5:22 am

    Untested, but I think this will work

    @echo off
    setlocal disableDelayedExpansion
    for /f "delims=" %%F in ('dir /b /ad /s _TEMPLATE_*') do (
      set "fname=%%~nxF"
      set "fpath=%%~dpF"
      setlocal enableDelayedExpansion
      ren "!fpath:_TEMPLATE_=Stores!!fname!" "!fname:_TEMPLATE_=Stores!"
      endlocal
    )
    

    It is perhaps a bit tricky because the loop is modifying the folder names of the hierarchy that it is enumerating. The parent folder of each folder will already have been renamed by the time it gets there.

    It will not give the correct results if your root path that is not getting renamed also has _TEMPLATE_ in the name.

    I toggle delayed expansion within the loop to protect against corruption of ! in path names during expansion of the FOR variable. If you know that no folder names contain ! then you can use SETLOCAL EnableDelayedExpansion at the top and remove the SETLOCAL and ENDLOCAL from the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read this post How can I use WCF with only basichttpbinding, SSL
I have read this post about how to test private methods. I usually do
hey guys, i have read This post, so what i got is JSON is
I have read through Scott Hanselman's post on this topic. I found another article
EDIT2 Looks like I can't read properly, disregard this post, I will try to
I have read through this post over and over, and yet it doesn't make
I have read this question but it's not quite what I was looking for.
I have read this article from High Scalability about Stack Overflow and other large
I have read this article about 400% boost of your website . This is
I have read this. Jquery checkbox <input type=checkbox name=checkGroup id=all> <input type=checkbox name=checkGroup id=one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.