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

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

$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 $_
    }
}