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

  • SEARCH
  • Home
  • 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 7128567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:09:07+00:00 2026-05-28T11:09:07+00:00

I have a parent folder called myfiles which contains several children folders. Each of

  • 0

I have a parent folder called “myfiles” which contains several children folders.
Each of those children has its own file1.txt

What I need to do is make a copy of file1.txt and rename each to file2.txt in each respective child folder (I need to do this from a command prompt in windows).

The goal is to have every child folder contain a file1.txt and a file2.txt

I’ve nearly got it with this:

for /r %G in (file1.txt) DO copy %G file2.txt

This command will loop through (when run from the myfiles parent location) and look for any instance of file1.txt and make a copy renamed to file2.txt

But the problem with this is, that instead of file2.txt being created inside each respective child directory, it is being created inside the parent directory (and consequently asking me to overwrite itself each time).

I know I’m close, but any help would be great.

  • 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-28T11:09:07+00:00Added an answer on May 28, 2026 at 11:09 am

    This would be a quick and dirty way:

    for /r %%a in (file1.txt) do (
        copy "%%a" "%%a.TMP"
        ren "%%a.TMP" "file2.txt"
    )
    

    The snippet above will create a copy into the correct directory with .TMP appended and then rename the copy to file2.txt.

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

Sidebar

Related Questions

I have a parent-/child relationship of folders, which looks like this: A folder can
I have a parent folder that contains inside it multiple folders named Project-* (folders
I have this much: A table which used to store the Folders. Each folder
I have a parent component, say P, which has function, say Pfunc. I also
I have a parent class which contains a child object. I am using set
I have two different folders located not under the same parent folder. Is it
I have a folder structure which I need to store in a database. Each
If you have Parent has_many :children Child Is there any reason a foreign key
I have a parent thread (non-UI) which creates some child threads to do some
I would like to get just the name of the parent folder of which

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.