Windows XP Copy a file to multiple folders.

Joined
Nov 23, 2007
Messages
2
Reaction score
0
Hi, wonder if anyone can help.



I need to copy a file to multiple folders. I have a parent folder X:\Documents with around 2000 account folders inside and I need to copy a template document to each of these folders.



I found a batch command yesterday that kind of did the job it was



For /R X:\Documents %a in (.) do copy C:\template.doc %a



I ran this and it worked so far as it copied the template to each of the user folders, however each of the account folders contained a subfolder called bills. X:\Documents\(account folder name)\Bills

The template was also copied to each of these bills folders.



So my question is how can I modify this command to copy the template just into each account folder?
 
Joined
Feb 3, 2006
Messages
147
Reaction score
1
Has Ian's reply resolved this question?


If not then the problem is due to the use of /R which walks the whole directory tree.

A command which should work is

for /D %a in (X:\Documents\*) do copy C:\Template.doc "%a"

I found that without the "" around %a the command will not accept subdirectory names with spaces. The /D restricts the for to directory names in the set X:\Documents\* and so does not go down to subdirectories.
 
Joined
Nov 23, 2007
Messages
2
Reaction score
0
Thanks guys, ended up outputting a list of folder names and creating a .bat file instead. But would have been a lot easier if I could have worked that command out.


It's amazing how much more powerfull CMD is than the GUI. Thankfully I now know for next time :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top