从路径中带有通配符的目录结构复制文件

Copying files from directory structure with a wildcard in the path

这看起来非常简单,但我不知怎么的无法让它工作,所以希望你们能提供帮助。

我有一个非常大的 Winforms 解决方案,我试图在构建之后提取所有 dll。在构建过程中,我的构建将所有 dll 推送到每个项目中的一个文件夹中,因此我最终得到了一个类似的文件结构。

结构是这样的,但项目名称不同:
C:\solution\project1\bin
C:\solution\project2\bin
C:\solution\project3\bin

我认为 运行 像下面这样的 xcopy 命令复制到一个位置真的很容易,但我不确定如何在路径中使用通配符:
xcopy C:\solution\???\bin\*.dll C:\Output

xcopy 可以吗?如果没有,任何其他建议,也许是 powershell?

感谢您提供的任何帮助。

Powershell 解决方案:

$srcPath  = "C:\mySource"
$destPath = "C:\myDest"

# Generate List of files with the .dll extension in $srcPath
$fileList = (Get-ChildItem -Path $srcPath | Where-Object {$_.Extension -eq     ".dll"}).FullName

# Copies files to new destination $destPath
foreach ($file in $fileList){
    Move-Item -Path $file -Destination $destPath
}

只需将 $srcPath 和 $destPath 变量替换为所需位置即可。