替换某文件夹下所有文件中某个字符串
- 作者: 段界撸神
- 来源: 51数据库
- 2022-08-17
$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 $_
}
}
推荐阅读
