We help IT Professionals succeed at work.

batch for sub directories name take and copy to a file

739 Views
Last Modified: 2014-08-09
Hello I have a directory c:\data with a lot of sub directories we want a script that look inside each sub directory for the file resources.html
   All sub directories contain a different resources.html because of that we want the batch.
   Now the batch once found the resource.html the script must copy that file resource.html but with the same of the sub directory name where its the main resources.html
   For example:
  In c:\data we have 2 sub directories c:\data\app2 and c:\data\app3 this is just an example because actually we have hundred of sub directories there.
  Now in our example like I mentioned each sub directory has its own resources.html it means something like that c:\data\app2\resources.html and c:\data\app3\resources.html and so on for hundred directories now the batch must copy each resources.html with the name of the sub directory where was taken and with same destination in other words the resulting copied files will be:
    c:\data\app2\app2.html and  c:\data\app3\app3.html note that app2.html and app3.html are the new files copied, the relation is: app2.html is the resources.html that correspond to sub directory c:\data\app2\resources.html and app3.html is the resources.html that corresponds to c:\data\app3\resources.html is like just copy the resources.html in the same directory but with name of the sub directory where it is its resources.html in other word and with destination in same sub directory and note also the name is just app2.html and app3.html and the name c:\data was ignored for each name of the new files; for c:\data\app2\ juts we take the app2 section to name the app2.html and ignore the c:\data and the similar for app3 and of course like we have hundred of sub directories with different names that will be the dame procedure for all.
I hope someone can help for a batch fo ms dos command prompt.
Thank you
Comment
Watch Question

IT Consultancy
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Works perfect
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
NP, try typing that on a phone :-)

Steve

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.