views:

97

answers:

2

Hi,

I'm trying to copy one or two specific files from a bunch of directories (hence why I don't want to/can't use *) from one directory to another using a batch script.

Basically I want to navigate into a "root directory" and from that list all the sub-directories using dir /AD-H /B then I want to cd into each of those directories and xcopy /y into a directory I have stored in a variable.

I've tried some examples I've found on the web, but when I've modified them they have not been able to handle the switches properly.

Thanks

A: 

Look into PHP an list the directory recursively into an array, here is a Example but you would need to modify it to fit your needs

Phill Pafford
A: 

With PowerShell, you can use something like:

Get-ChildItem C:\ | ? {if ($_.PSIsContainer) {Copy-Item -include MyFile1.ABC -path $_.FullName -destination ("E:\Test\" + $_.Name) -recurse}}

Replace C:\ with the "Root Directory" to copy from and replace "E:\Test\" with the "Root Directory" to copy to (or to use an environmental variable DestX, replace "E:\Test\" with $env:DestX.

Gordon Bell