【发布时间】:2014-02-28 18:58:30
【问题描述】:
我想替换多个文件和文件夹中的文本。文件夹名称更改,但文件名始终为 config.xml。
$fileName = Get-ChildItem "C:\config\app*\config.xml" -Recurse
(Get-Content $fileName) -replace 'this', 'that' | Set-Content $fileName
当我运行上述脚本时,它可以工作,但它会将整个文本写入 config.xml 中大约 20 次。怎么了?
【问题讨论】:
标签: file powershell replace directory