can you help me with find a some script to help me to replace a string from one to another file.
for example in test1.xml i have string id=“123”, and i want to copy it to test2.xml instead of id=“1” to be “123”
i tried with some script:
[code]
Original text
$inputFile1 = “C:\ephemeral\file1.xml”
Text to be inserted
$inputFile2 = “C:\ephemeral\file2.xml”
Output file
$outputFile = “C:\ephemeral\file3.txt”
Find where the last tag is
if ((Select-String -Pattern “uid=” -Path $inputFile1 |
select -last 1) -match “:(/>\d+):”)
{
$insertPoint = $Matches[1]
# Build up the output from the various parts
Get-Content -Path $inputFile1 | select -First $insertPoint | Out-File $outputFile
Get-Content -Path $inputFile2 | Out-File $outputFile -Append
Get-Content -Path $inputFile1 | select -Skip $insertPoint | Out-File $outputFile -Append
}[/code]
but i am not sure why he use 2 input and 1 output files. idont get it…
Edited at the request of OP - WA