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

2015-11-10 0 603
替换某文件夹下所有文件中某个字符串
$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 $_
    }
}

遇见资源网 shell 替换某文件夹下所有文件中某个字符串 http://www.ox520.com/17244.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务