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

时间:2016-03-09 22:11:00

标签: xcopy

这看起来非常简单,但我无法让它发挥作用,所以希望你们可以提供帮助。

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

结构将是这样但具有不同的项目名称:
C:\解决方案\ Project1的\ BIN
C:\解决方案\项目2 \ BIN
C:\溶液\项目3 \ BIN

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

这可以用xcopy吗?如果没有,任何其他建议,也许PowerShell?

感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

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变量替换为所需的位置。

相关问题