Hello I have around 5000 text files (TXT) in one directory.Files are comma delimited. What I'm trying to do is to change date format (it is stored in first column of each file) from M/d/yyyy to MM/dd/yyyy. There is around 1 milion lines in those 5000 files so I hope there is some efficient way to do it.I read somewhere that for handling such a big number of data a StreamWriter command is a way to go, but I'm not sure if it can be used in my case. Thank you for any suggestion.
I'm using this script for deleting second and last row of multiple text files using StreamWriter. It is very fast and efficient. I hope that with some small modifications it can be used for changing date formats in first column. I have just 2 weeks experience with PS so this is quite a challenge for me.
dir *.txt | %{
$content = gc $_.FullName
$output = @($content | select -First 1 )
$output += $content[2..($content.count -2)]
$sw = New-Object System.IO.StreamWriter($_.FullName,$false)
$output | %{$sw.WriteLine($_)}
$sw.close()
}