0
votes

I've been trying to find a solution to this but can't find any . Maybe someone has an idea on this.

I have file1.txt which has one value per each line, and another file2.txt which has other values on each line.

file1.txt

green
blue
red
[etc]

file2.txt

1
2
3
[etc]

I am trying to add all the values from file2.txt to the END of each of the values from file1.txt

The final output file will look like this

output.txt

green1
green2
green3
blue1
blue2
blue3
red1
red2
red3
[etc]

I've tried this in Excel to copy the values but it crashes.

Ideally i'm looking for a way to do this on Windows: maybe a PowerShell command, or a regex expression somehow with a cmd prompt command?

As these 2 files have lots of data, i don't see it working with Excel as it crashes constantly.

Don't look at 1,2,3 as a pattern in file2.txt, they can be anything other than numbers; so there is no pattern there; it's just diff values compared to file1.txt

Would greatly appreciate any solution on this,

Thank you!

PS: in some cases I have 500k lines on file1.txt, and 1000 lines on file2.txt; ideally I'd only use a cmd prompt or PowerShell command to work with the files..

1

1 Answers

1
votes

Windows 10 64-bit

cmd:

cd.> file3.txt
for /f %a in (file1.txt) do for /f %b in (file2.txt) do echo %a%b>> file3.txt 
file3.txt 

script:

cd.> file3.txt
for /f %%a in (file1.txt) do for /f %%b in (file2.txt) do echo %%a%%b>> file3.txt
file3.txt