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

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

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


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

There are about 40 folders under the c:\ dir.
Question by:joe90kane
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 84

Accepted Solution

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"

Author Comment

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 =


Thanks again.
LVL 84

Expert Comment

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.

Author Comment

ID: 17142127
Thanks for the info.

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem pinging RRAS server from outside the network 11 101
AD user acount change history 4 75
Unknown AD user under VMWare OU 4 71
Can’t delete a file 14 196
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
Learn about cloud computing and its benefits for small business owners.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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