user3246980
user3246980

Reputation:

Combining 2 Large Text Files

I'm trying to combine 2 large text files in Windows 10 (200mb each) but it seems that my usual method Command Window >> Copy *.txt Combine.txt doesn't work. The outputted file is the size of only one of the files so I'm assuming that method doesn't work for large files. Is there another way I can do easily this?

Upvotes: 0

Views: 760

Answers (2)

Robert Cotterman
Robert Cotterman

Reputation: 2268

You can simply append it

Get-content file1.txt | out-file c:\combined.txt -append
Get-content file2.txt | out-file c:\combined.txt -append

A much faster method is .net ReadLines

[System.io.file]::readlines("c:\file1.txt") | out-file c:\combined.txt -append
[System.io.file]::readlines("c:\file2.txt") | out-file c:\combined.txt -append

Upvotes: 3

HariHaran
HariHaran

Reputation: 4099

If the destination file does not already exist or already contains content, you’ll want to issue the New-Item command first. If you know it doesn’t exist or is empty, you can skip that line, below.

New-Item -ItemType file ".\combined_files.txt" –force

Get-Content .\file?.txt | Add-Content .\combined_files.txt

Upvotes: 1

Related Questions