Sign in to follow this  
Followers 0
iceberg

copy contents of 100s of text file into a new text file

8 posts in this topic

hi guys,

i remember there was a post on this....i tried searching for it but cdn't locate it.

would appreciate if someone could direct me to it by providing the link to the post.

thanks.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites



you could also use a for loop to write the command to a .bat file so you don't have to type so much, and then you could run the .bat file.

Share this post


Link to post
Share on other sites

If the files are all in one folder then you could just use _FileListToArray() and then loop through the array.

Where $fList is the array returned from _FileListToArray()

If IsArray($flist) Then
   $Out = ""
   For $I = 1 To Ubound($fList)-1
      $Out &= FileRead($fList[$I]) & @CRLF
   Next
   FileWrite("My_New_File.txt", StringStripWs($Out, 2))
EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

thanks alot everyone!


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

or Use RunWait() with this:

"type *.csv >> test.txt"

Share this post


Link to post
Share on other sites

hi all,

i managed to resolve the issue in this manner.

thanks for all your help anyway.

$search = FileFindFirstFile("*.txt")

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern - *.txt")
    Exit
EndIf

$x = 0

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop

    $open = FileOpen($file, 0)
    
    If $open = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf
    
    $x = $x + 1
    
    $chars = FileRead($open)
    If @error = -1 Then ExitLoop
;MsgBox(0, "Char read:", $chars)
    FileWrite("output.doc", $chars & @CRLF)
    FileClose($file)
    SplashTextOn("Monitor Status", "Current File : " & $file & @CRLF & "Number of files processed : " & $x, 400, 50, -1, -1, 33, "", 12)
WEnd

SplashOff()
FileClose($search)
MsgBox(0, "Status", "All completed.")
Exit

mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

There is Udf (Sorry i cant rem. who post it ) but its not mine

CODE
Func _FileGetNewest($s_Path = @MyDocumentsDir, $s_Mask = '*', $i_Flags = 1)

Dim $a_File, $s_NewestFileName = '', $s_NewestFileDate = '', $s_FileName = '', $s_FileDate = ''

$a_File = _FileListToArray($s_Path, $s_Mask, $i_Flags)

If Not @error Then

For $i = 1 To $a_File[0]

$s_FileName = $s_Path & '\' & $a_File[$i]

$s_FileDate = FileGetTime($s_FileName, 0, 1)

If $s_FileDate > $s_NewestFileDate Then

$s_NewestFileName = $s_FileName

$s_NewestFileDate = $s_FileDate

EndIf

Next

EndIf

Return $s_NewestFileName

EndFunc

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
Sign in to follow this  
Followers 0