【发布时间】:2015-11-13 14:46:50
【问题描述】:
我有两个文件夹。
Folder1 包含许多文件。
Folder2 是用于 folder1 中一组文件的服务包。
我想通过 PowerShell 将 Folder1 中的特定文件替换为 Folder2 中的文件。
-Replace 是正确的起点吗?我应该如何处理?
更新
Get-ChildItem $hotfix | ForEach-Object {Copy-Item $_.FullName -Destination $original -force}
【问题讨论】:
-
查看
copy-item和-force以覆盖,返回一些您尝试过但遇到问题的示例。-Replace更多的是字符串替换相关而不是文件/目录相关。 -
我尝试了以下代码,它运行良好 -Get-ChildItem $hotfix | ForEach-Object {Copy-Item $_.FullName -Destination $original -force}
-
干得好,干得好。
-
@ruchasn 发布答案!
标签: powershell powershell-2.0 powershell-ise