Jump to content

Recommended Posts

Posted

Hello!

I am new to autoit so please if someone could help me. I am trying to combine multiple .txt files but I can't get it right. In every file are the exact amout of lines ( for example here are 2 ) ,            I don't want to make it for just 2 lines for each txt files but for all the lines the txt files contains. The thing I want to do is :

Text File 1

Hello my name

I am a big

...

Text File 2

is Fred,

Potato head for

...

Text File 3

and I like to eat pizza.

Not getting this right.

...

------------------- Combine them all into one txt file like here ------------------------------

Final Text file

Hello my name is Fred, and I like to eat pizza.

I am a big Potato head for Not getting this right.

...

 

Thanks for any advice!

P.S. Sorry for my English, not my first language.

 

Posted

Nvm got it!

#include <File.au3>
#include <MsgBoxConstants.au3>

Global $file1 = "C:\Users\Malach\Desktop\Script\start.txt"
Global $file2 = "C:\Users\Malach\Desktop\Script\mid.txt"
Global $file3 = "C:\Users\Malach\Desktop\Script\end.txt"

Global $filefinal = "C:\Users\Malach\Desktop\Script\final.txt"

Global $line1
Global $line2
Global $line3

Global $y = _FileCountLines ( $file1 )
Global $x = 1


While $y > 0
FileOpen($file1, 0)
$line1 = FileReadLine($file1, $x)

FileOpen($file2, 0)
$line2 = FileReadLine($file2, $x)

FileOpen($file2, 0)
$line3 = FileReadLine($file3, $x)

Local $lineunite = $line1 & $line2 & $line3

FileWriteLine ( $filefinal, $lineunite )
$x = $x + 1
$y = $y - 1
Wend

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...