Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Help required with file copy script/ batch file please !

Nov 17, 2011 5:39AM PST

Hi i'm a scripting newbie and require some help with a script i am trying to writ.

What I need to do is to. Replicate a folder called "migration" to every folder within a directory.

I have a script which will copy a folder (from file path writen into the script)
Into a folder within the directory (also written into the script) but have no idea how to make it write to all folders within the directory.

I have also tried writing a batch file which enumerates all the folders within the directory and then exports them to c:\folderlist.xml

I have been trying to use robocopy to copy "migration" to every folder within the directory using the .xml as the reference but not having much luck.

Is anyone in a position to help me please ?

Discussion is locked

- Collapse -
Answer
Read posts 8, 9 and 10 at link.
Nov 17, 2011 5:49AM PST
- Collapse -
Thanks but i need a command to copy folders :)
Nov 17, 2011 7:15AM PST

Thanks !

The link was helpfull but dosn't bring me any closer to what I require Happy That command will copy files to every folder but not folders.

I am trying to copy a folder called "migration" to all top level folders within a directory.

I have tried using robocopy. Can anyone help ? Happy 1 folder to many within a single directory ?

Thanks Muz

- Collapse -
I think you are looking for
Nov 17, 2011 7:22AM PST

While the link I gave helps us script a copy to each folder I think what you are really looking for is the exact solution without having to create it on your own.

Let's hope some programmer here will pop in soon but your task would be done in about 2 minutes with that folder on your desktop and a drag and drop to the folders one by one in the explorer pane.
Bob

- Collapse -
Stil havn't found what I'm looking for !
Nov 17, 2011 7:53AM PST

HI

Well you are half right !! I am looking for some help with the solution .... but i have been trying to create it myself !
However my I think i am fairly limited by my knowledge of the robocopy/xcopy/copy command and syntax's, I have searched tech net and created loads of batch files which will copy/ replicate my "migration" folder to a specified(in the script) folder.

I have also tried a VBS but again my limited knowledge has only allowed me to to write a script to copy the "migration" folder to one specified(in the script) folder. !!!

However my problem is getting the command to replicate to all top level folders within the specified directory.

I also agree that drag and drop from/to windows explorer is a solution ..... not when this replication needs to be done 1000's of times and not only for this one off task Happy

Let's hope a programmer can help me out !

Thanks for your help anyway

Muz

- Collapse -
Re: script
Nov 17, 2011 5:19PM PST

I see 2 options:
1. Write a simple vbscript that generates a batch file that uses xcopy /s to do the job. That file should have 1 line for each target folder.
2. Write a more complex vbscript that does it all itself, recursively.

There might be alternatives by using powershell, but I don't know that.

As this seems to be for work, there should be money to pay someone to write it if you can't do it yourself.

Kees

- Collapse -
I think Kees has it nailed.
Nov 18, 2011 12:01AM PST

Vbscript opens the door for a richer script language. And it's more likely to work across machines.

It's also an easier language to pick up than COMMAND.COM or CMD.EXE scripting.
Bob

- Collapse -
Nailed nothing
Nov 18, 2011 1:06AM PST

To be honest Kees hasn't nailed anything ! He has stated the obvious !

I have a problem (due to my lack of subject matter knowledge) and am seeking help !!

I you are not in a position to offer any ! Please don't waste your time answering ! Lol !!

It's like someone whos been trying to fix their cars alternater, posting asking any mechanics how to replace the brushes..... only to be told.

Yes you have a problem ... you can either :
1 Call out a Mechanic
2 Go to a garage
3 Go to Mechanic school for a couple of years then you'll know how

All i'm asking for is some help !!! I seriously wonder sometimes why people cannot just help each other out in this day and age !!

Unbelievable !!!

- Collapse -
Sorry but rarely do others write the code for you.
Nov 18, 2011 1:14AM PST