Combine two text files with powershell
I have two text files with data.
First text file contains a big list of fullpaths to my files. d:\cat\cat1.txt
d:\test\file1-1.txt d:\test\file1-2.txt .... d:\test\file1-N.txt
Second text file contains a short list of fullpath to my \files
I need third file which contains
d:\test\file1-1.txt d:\test\file1-2.txt d:\test\file2-1.txt d:\test\file1-3.txt d:\test\file1-4.txt d:\test\file2-2.txt d:\test\file1-5.txt d:\test\file1-6.txt d:\test\file2-1.txt
Thx for help.
If you want to combine multiple files ( 2 or more ), you can do:
gc d:\cat\cat1.txt,d:\cat\file\cat2.txt | out-file d:\cat\combinedcat.txt
It is not clear from your example what kind of "specific" combination you want, so you may want to explain that, but the logic for combining files will be like above.
Get the content of both files and save output to a new file:
Get-ChildItem d:\cat\cat1.txt,d:\cat\file\cat2.txt | Get-Content | Out-File d:\cat\cat3.txt