0
我试图从一个文件夹复制到另一个文件,然后将更改应用到像这样复制的文件...PowerShell的复制和设置内容
#Get all HTML files and copy them to Folder2
$allHTML=get-childitem $PSScriptRoot *.html
$copyPath = "Folder1/Folder2"
foreach ($all in $allHTML)
{
Copy-Item $all $copyPath
}
#Get all HTML files inside Folder2, change and re-save them
$copyHTML=get-childitem $copyPath *.html
foreach ($allFiles in $copyHTML)
{
(Get-Content $allFiles) | ForEach-Object { $_ -replace "this text", "with this text" } | Set-Content $allFiles
}
我有一种感觉它的设置,这就是内容不正确,因为此代码将更改原始文件,而不是文件夹2中的副本...
任何人都可以请帮我吗?
感谢
你真的要写的文字或追加的文本? – Rahul