Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy one file to many folders 1

Status
Not open for further replies.

jamus

IS-IT--Management
Sep 20, 2002
14
SG
Does anyone know how I can copy or transfer a file to a folder and all its subfolders without having to do it one at a time?

any help much appreciated.

jamus
 
How or what are you attempting to use to does such a task?
Are FTP'ing(WS_FTP or command line), Using Windows explorer(drag and Drop), Dos (xcopy)???
 
There are various ways of doing this. How about the following in a batch file

for /f %%i in ('dir /ad /s /b') do copy %1 %%i

This will the copy the file you specify (ie %1) to all subdirectories but actually misses out the top level subdirectory, so you can just add that as a 2nd line in the batch file.
 
hi and thank you both for your help, I was working on creating a warm server back up for my PDC and needed to copy a file to multiple folders to capture NTFS permission.

Have found a work around using 3rd party apps.

Still, thanks for the help.

regards.

jamus
 
This is almost exactly what I need for a task I have outstanding, the only difference is that I wish to copy a particular file out to a specifed sub-folder level on a group of users personal drives.

Example:

I have a file called file.txt on the root of D:\ and I wish to copy it into the App folder of all users D:\username\app folders, where I have around 200 Username folders.

So it looks a bit like this:

D:\user1\app
D:\user2\app
D:\user3\app

and the final complication is, that if the file already exists, it shouldn't overwrite it!

Can this FOR command be adjusted to do this?

Regards
Nigel Smee
 
It should work for that. If you run the batch file in the root of D: then you probably want something like

for /f %%i in ('dir /ad /b') do if not exist d:\%%i\app\file.txt copy file.txt d:\%%i\app

I haven't tested this so you may need to play around with it to get it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top