Good day,
in a specific directory under Win 8.1, I have these hundreds of text files with the extension *.xml, representing a Web site.
In each and every of those files there is exactly one occurence of a certain tag with a known content, say <tag>old</tag>
.
In all these pages, this specific text needs to be replaced by <tag>new</tag>
. Subdirectories exist, but they do not need to be examined.
How would I automate this task? (I am not familiar with the PowerShell, don't think I've ever used it, but would that be heading into the right direction? If not - apologies for the misleading tag.)
Thanks in advance!
Try this PowerShell script.
$myFiles=get-childitem C:\Folder *.xml -rec
foreach ($file in $myFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object {$_ -replace "<tag>old</tag>", "<tag>new</tag>"} |
Set-Content $file.PSPath
}