I'm writing a windows powershell script to open/edit a text file.
It has many records and each record is sorted of comma-separated values (csv):
Steps I want to achieve:
- Open the text files in a directory on Server A.
- Edit the "Date" field with "Current Date" or other.
- Save the same text file at the same location(folder).
- Copying all the files to a new folder in different Server B.
I've just written this code snippet:
$path = "C:\PSFiles\Rec_File_001.txt"
$Filedata = Get-Content $path
$Record01 = $Filedata[0].split(",")
$Record01Date = $Record01[3]
$Record01CurrentDate = Get-Date -format yyMMdd
$Record01 -replace $Record01Date, $Record01CurrentDate
Set-Content $path
Please, any help on this?