Solved

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

Posted on 2006-07-19
4
452 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
[X]
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
4 Comments
 
LVL 84

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 84

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PowerShell one liner to pull server names 3 68
Forcibly removing a 2003 server from the Domain 4 68
2003 File Server upgrade 11 86
Cannot take ownership of a folder 8 89
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…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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