Merge Multiple Text Files into One with PowerShell
Concatenate many .txt/.csv/.log files into a single file with Get-Content, Set-Content or cmd's type/copy.
01Command
$ Get-Content 'C:\Logs\part-*.txt' | Set-Content 'C:\Logs\merged.txt'02What it does
Get-Content with a wildcard reads each matching file line by line in alphabetical order, and piping into Set-Content writes it all to one new file. If you need a label between files, loop instead: Get-ChildItem *.txt | ForEach-Object { "=== $($_.Name) ==="; Get-Content $_ } | Set-Content merged.txt. In plain cmd, copy /b part-*.txt merged.txt or type part-*.txt > merged.txt does the same job without PowerShell.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Get-ContentEvidence: Get-Content with wildcards reads the line contents of all matching files in order, ready to pipe into a single output file.
- Get-Content - SS64Evidence: Demonstrates piping Get-Content output of multiple files into a combined file.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
Search inside text files and logs with regex, returning file, line number and match.
Built-in PowerShell comparison that lists lines unique to each file.
Diagnose NTFS file system errors and bad sectors on any volume — including the system drive while Windows is running — before committing to a repair.