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

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
  • 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Event ID: 2005 / Source: Microsoft-Windows-PerfNet 4 105
Unknown AD user under VMWare OU 4 66
Migration of AD user accounts from Server 2003 to 2012R2 5 94
ticket bloat 3 51
The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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