Combine two text files with powershell

powershell

Solution

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.

Problem

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 d:\cat\file\cat2.txt ``` d:\test\file2-1.txt d:\test\file2-2.txt ``` 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.

Original source

Related problems