Jump to content

Append line-by line file?


Recommended Posts

Weird topic name but what I want to do is have a script which takes one file and appends it to another but LINE BY LINE, as shown below.

file 1:

i love

i like

that is a

file 2:

dogs

cats

gorilla

and the finished file would be like this:

i love dogs

i like cats

that is a gorilla

any idea how to do that?

Link to comment
Share on other sites

Weird topic name but what I want to do is have a script which takes one file and appends it to another but LINE BY LINE, as shown below.

file 1:

file 2:

and the finished file would be like this:

any idea how to do that?

$avFile1 = _FileReadToArray($File_1)
$avFile2 = _FileReadToArray($File_2)
$hFile3 = FileOpen($File_3, 2)
$x = $avFile1[0]
If $avFile2[0] < $x Then $x = $avFile2[0]

For $n = 1 To $x
      FileWriteLine($hFile3, $avFile1[$n] & " " & $avFile2[$n])
Next

FileClose($hFile3)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Argh, did it but went afk for a minute. Psalty beat me.

Here is what I did:

#include <file.au3>
Dim $as_File1, $as_File2
_FileReadToArray("file1.txt",$as_File1)
_FileReadToArray("file2.txt",$as_File2)

Dim $i_Count
For $i_Count = 1 To UBound($as_File1)-1
    $as_File1[$i_Count] &= " " & $as_File2[$i_Count]
    If $i_Count = Ubound($as_File2)-1 Then Exitloop
Next

_FileWriteFromArray("File3.txt",$as_File1,1)

ShellExecute("File3.txt")

Hope that helps.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...