替换某文件夹下所有文件中某个字符串

2019-06-16 02:07栏目:技术创新

$FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog
if($FolderBrowserDialog.ShowDialog() -eq 'OK'){
    $DirName = $FolderBrowserDialog.SelectedPath   "\*"
    Get-ChildItem $DirName -include *.xml | foreach-object{
        $content = Get-Content $_
        $newname = "/xx/xxxxxxx/xxx/"   $_.name.SubString(15,4)   ".html"
        $content -replace "/xx/xx/xx/xx.html", $newname | Set-Content $_
    }
}
#该片段来自于http://outofmemory.cn

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:替换某文件夹下所有文件中某个字符串