Solved

Bat script to copy a file to all folders in a directory

Posted on 2006-07-19
4
448 Views
Last Modified: 2010-04-18
Hi all,

I need a .Bat script to copy a file to all folders in a directory

e.g.

Copy "C:\app.mdb" "C:\All folders in the C:\ directory"

There are about 40 folders under the c:\ dir.
0
Comment
Question by:joe90kane
  • 2
  • 2
4 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 17141392
Open a command prompt at the root of C:, run this batch (it will exclude your Windows folder from the folders the file should be copied to):
@echo off
for /d %%a in (*.*) do (
  if /i not "%%a"=="%Systemroot%" copy C:\app.mdb "%%a"
)
0
 
LVL 1

Author Comment

by:joe90kane
ID: 17141567
Thanks for that oBdA it works great, before I accept the answer would you be so kind to explain the script

/d =
/i =

etc...

Thanks again.
0
 
LVL 83

Expert Comment

by:oBdA
ID: 17141796
"for /d ..." will run the "for" loop only for *d*irectories, not for files (enter "help for" for more possibilities).
"if /i ..." will run the comparison case *i*nsensitive, otherwise "Windows" and "WINDOWS" would be different.
0
 
LVL 1

Author Comment

by:joe90kane
ID: 17142127
Thanks for the info.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now