PowerShell: Join Files

By Xah Lee. Date: . Last updated: .

Join 2 Files

# create files
New-Item "~/xtest1.txt" -value "aaa"
New-Item "~/xtest2.txt" -value "bbb"

# join them into xnew.txt
Get-Content -Path "~/xtest1.txt", "~/xtest2.txt" | Set-Content -Path "xnew.txt"

Join All Files in a Dir

# join all html files in a dir into single file
Get-Content "*html" -Raw | Set-Content -NoNewline "xnew.html"

PowerShell. Working on Files