How to remove string and replace with content found in text file using batch script.
test.txt
Version: 4.5.0 Import: //MPackages/Project/config/abc.txt #head //Packages/Project/config/cde.txt #head View: 24234 //MPackages/Project/config/ac.txt #head Remove any text found between "Import:" and "View:" and replace it with content from sample text file..
sample.txt
1 2 3 Desired output
Version: 4.5.0 Import: 1 2 3 View: 24234 //MPackages/Project/config/ac.txt #head sample script
[string]$f=gc Test.txt; $pL=$f.IndexOf('Import:')+'Import:'.Length;$pR=$f.IndexOf('View:'); $s=$f.Remove($pL,$pR-$pL) | set-content Test.txt i removes everything between Import: and View: but it ruins text structure.