
正文
Powershell 批量替换文件
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
Powershell 批量替换文件##作者:Xiongpq
##时间:2015-06-10 18:50
##版本:2.0##源文件目录
##源文件目录的所有文件都会覆盖目标目录的同名文件,源文件目录可以在目标目录内,不会循环覆盖
$source = 'E:\Test_Target\Test_Source\'
##目标目录,支持多个目录
$target = 'E:\Test_Target\',
'D:\Test_Target'$sourceItem = Get-ChildItem -Path $source -recurseforeach ($sourceFileName in $sourceItem)
{
$targetItem = Get-ChildItem -Path $target -include $sourceFileName.Name -recurse
foreach ($targetFileName in $targetItem)
{
if ($targetFileName.FullName -ne $sourceFileName.FullName){
Copy-Item -Path $sourceFileName.FullName -Destination $targetFileName.FullName -Force
}
}
}
Write-Host("DONE.....................")
##作者:Xiongpq
##时间:2015-06-10 18:50
##版本:2.0##源文件目录
##源文件目录的所有文件都会覆盖目标目录的同名文件,源文件目录可以在目标目录内,不会循环覆盖
$source = 'E:\Test_Target\Test_Source\'
##目标目录,支持多个目录
$target = 'E:\Test_Target\',
'D:\Test_Target'$sourceItem = Get-ChildItem -Path $source -recurseforeach ($sourceFileName in $sourceItem)
{
$targetItem = Get-ChildItem -Path $target -include $sourceFileName.Name -recurse
foreach ($targetFileName in $targetItem)
{
if ($targetFileName.FullName -ne $sourceFileName.FullName){
Copy-Item -Path $sourceFileName.FullName -Destination $targetFileName.FullName -Force
}
}
}
Write-Host("DONE.....................")








