# Combine multiple files into one

## Recommended Posts

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,

...

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.

...

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

##### Share on other sites

Not much of a signature, but working on it...

Spoiler

##### Share on other sites

@Nine I've tried, the closest I got was that i merged all 3 but it was pasted every time under the lines, not behind them.

##### Share on other sites

Show your code, we will check on it...

Not much of a signature, but working on it...

Spoiler

##### Share on other sites

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 #### Share this post ##### Link to post ##### Share on other sites ## 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 • ### Recently Browsing 0 members No registered users viewing this page. • ### Similar Content • hello evrybody here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum with$i_number
e.g
you have a long text and you want to split it in an array
that evry colum have a number (n) of lines
i made a function that do that for you
just call it with a three params
$s_text your text$i_number
the number that you want to put in each col
$s_siparator the siparator default is "|" here is the function with example i hope that it will be useful for you **** #include <Array.au3>$s_txt = "some text1some text2|some text3|some text4|some text5|some text6" $array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text, $i_number,$s_siparator = "|") Local $a_TXT = StringSplit($s_text, $s_siparator) Local$a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <= $i_number) Or ($i_number <= 0) Then ReDim $a_Return[2]$a_Return[0] = 1 $a_Return[1] =$s_text Return $a_Return EndIf Local$i_Processed = 1, $i_arrayProcessed = 1 Do For$i = $i_Processed To ($i_Processed + $i_number) - 1 If ($a_TXT[0] < $i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then$a_Return[$i_arrayProcessed] =$a_TXT[$i] Else$a_Return[$i_arrayProcessed] &=$s_siparator & $a_TXT[$i] EndIf $i_Processed += 1 Next$i_arrayProcessed += 1 Until ($a_TXT[0] <$i_Processed) ReDim $a_Return[$i_arrayProcessed] $a_Return[0] =$i_arrayProcessed - 1 Return $a_Return EndFunc ;==>splitText accept my greetings thanks to @Dan_555 for his notes • hello autoit team please i've a question for you. am creating a audio player and in this audio player i want to show the current trac info such as the total time and the position ... etc i know i can show it as label but the screen reader for the blind read the text every change because it have a screen scan what i want is to show this informations but such image or icon i mean i need to create GUICtrlCreatepic or GUICtrlCreateicon .... or some thing as that and show this informations as image on it i think that i can do that with the _GDIPlus functions but i couldn't find the currect way to do it i tried the _GDIPlus_GraphicsDrawString but i couldn't know how it work what i need is a small example that create a GUI and add a multy line text to it as graphic or image. so i need a simple way because it will changed every sec i hope any one can help me to do that global$GUI = GUICreate("text", 400, 400) global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc • hello autoit group please i've a question i had make a function that put some thing into the clipBoard and paste it using the send function e.g ClipPut("hello") send("^v") when the keyboard is english all things work fine but when the keyboard is arabic the send command write the ltr v insted of the text in clipboard i was tryed to use send("{ctrldown}v{ctrlUp}") but the same please can any one help me • By Kruxe Hello Everyone, I am very green when it comes to AutoIT, I have recently started using it to automate a job that i perform using MS Excel and that is working great. Recently I have been faced with a challenge I which i need to copy a specific set of lines from one .txt file and past them, overwriting a specific set of lines in a different .txt file. I honestly have no clue how I can copy the specified lines and transfer them. What functions / commands could I use and how could I lay them out I AutoIT? Any and all help will be appreciated. Thanks! Kruxe • By ThePoro Hello, I have a problem with getting first 10 characters with a big txt file, about 50k lines. I only want 10 characters of each line and save it into another file. I tried to use Stringleft every line and save it into another file but it was really slow to do it. I tried to save it into a variation like$var=$var&stringleft($file,10)&@CRLF. It's faster but still really slow.
Can anybody help me with this
Thank you so much
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...