I want to select and combine the content of all html files, from Folder 1, to a single html File from Folder 2.
Can this be done with PowerShell ?
to avoid problem of memory if you have lot of files:
$rootFolder = "c:\Folder1"
$outfile = Join-Path -Path $rootFolder -ChildPath 'newfile.html'
$sw = New-Object System.IO.StreamWriter $outfile, $true # $true is for Append
Get-ChildItem -Path $rootFolder -Filter '*.html' -File | ForEach-Object {
Get-Content -Path $_.FullName -Encoding UTF8 | ForEach-Object {
$sw.WriteLine($_)
}
}
$sw.Dispose()