I have some text files looking something like this:
Text 05-09-18
Text 17-09-18
Text 17-09-18
Text 24-09-18
Text 17-10-18
On line 15 in the .txt files, I'm trying to change from 24-09-18 to 24-09-2018.
Changing only this and not the other ones.
- The [15] overrides the .txt file with a empty one.
- If [15] is not present then it changes all dates in the .txt file.
Here's what I'm been doing so far:
$infolder = Get-ChildItem C:\folder\*.txt -rec
foreach ($file in $infolder)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_[15] -replace '-18','-2018'} |
Set-Content $file}