molay Posted March 3, 2009 Share Posted March 3, 2009 Hi All, here is my concer : In a specific folder , I have couple text file created automatically every day with a specific format "mmddyyyyF1.txt",mmddyyyyF2.txt" I need to copy the contents of those created files and paste them at the end of an exsisting master files. masterF1.txt , masterF2. that are in other folder. Please help with the syntax i am really stuck here. Thanks Link to comment Share on other sites More sharing options...
bogQ Posted March 3, 2009 Share Posted March 3, 2009 from help file, list of commands that will probably help y to finde your best sutible solution FileReadLine _FileWriteToLine _FileReadToArray _ArrayAdd _FileWriteFromArray TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2009 Moderators Share Posted March 3, 2009 molay,First, welcome to the AutoIt forums.When you post here it always helps if you have had a go at solving your problems beforehand. Having some code to work on is a great help - and no-one here is too keen to help the "code it for me" brigade.Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. Using the Search facility is also a good tip as there is a pretty good chance your question has been asked before. Look for the "Search" button to the right in the title bar . In your case I would look carefully at FileRead and FileWrite. :-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
molay Posted March 3, 2009 Author Share Posted March 3, 2009 Hi M23, Thanks for the quick Reply. Sure i went through the Help which i find it very explicit and simple with the examples.For this specifc issue i was completely lost. I have to find how to copy the content of the txt file and copy it at last line of an exsisting one.. If you tell me that is in the help i will go back there to check .. Thanks a gain and sorry for that. Molay Link to comment Share on other sites More sharing options...
bogQ Posted March 3, 2009 Share Posted March 3, 2009 you already have what you need to get it to work Pls post some codes so that we see what did y try so that anyone can help you with your script. what you need is posible to do with this commands _FileReadToArray to read first file and to read second file _ArrayAdd to add lines from first array to second array _FileWriteFromArray to rewrite all the data from second array to document with fileread&write it si posible but it will b to slow if your working with alot of lines in document. so pls post some codes first, so that we can all see where y have problem and what did y try to do. TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2009 Moderators Share Posted March 3, 2009 molay,A one-time good deal! This assumes your files are text based - if we are talking binary we need to adjust a bit.FileRead will read the contents of the small files mmddyyyyF1/2.txt by using this:$sFile_Contents = Fileread("file_path")Then you add the contents to your "master" file by using this:FileWrite("master_file_path", $sFile_Contents)If you have problems, do as bogQ suggests and post the code that is not working. It is always easier to work when you have something to get your teeth into! (Can you tell I have just had dinner?)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
molay Posted March 9, 2009 Author Share Posted March 9, 2009 hi Guys, thanks for your help. I habe been able to have iot working correctly. But what when the 1nd file is updated i am having like indexed number in the header of the file. Is there a way to remove those numbers. here is my Code : #include <file.au3> #include <Array.au3> ;Read the first File ---------------------------------------------------------------- Dim $aRecords $file1 = "C:\Test1.txt" If Not _FileReadToArray($file1,$aRecords) Then ;MsgBox(4096,"Error", " Error reading text file to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) Next ;----------------------------------------------------------------------------------- ; Read The 2nd File Dim $bRecords $file2 = "C:\Test2.txt" If Not _FileReadToArray($file2,$bRecords) Then ;MsgBox(4096,"Error", " Error reading text file to Array error:" & @error) Exit EndIf For $x = 1 to $bRecords[0] ;Msgbox(0,'Record:' & $x, $bRecords[$x]) Next ;------------------------------------------------------------------------------------- ; Add lines from the 2nd file to the end of the 1st one For $i = 1 to $aRecords[0] _ArrayAdd($bRecords, $aRecords[$i]) ;_ArrayAdd($bRecords, $aRecords[$i+1]) ;_ArrayAdd($bRecords, $aRecords[$i+2]) ;_ArrayDisplay($bRecords, "$avArray AFTER _ArrayAdd()") ;Msgbox(0,'Record:' & $x, $bRecords[$x]) Next ;_ArrayDisplay($bRecords, "$avArray AFTER _ArrayAdd()") _FileWriteFromArray($file2, $bRecords, 0) and here is what i am getting in the file 2 " test2.tct " 5 1 2nd field 1st Update. 2nd update. 3rd Update. 1st Update. 2nd update. 3rd Update. I need to remove the 5 & 1 Any idea ? thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 9, 2009 Moderators Share Posted March 9, 2009 molay,From that ever useful Help file for _FileReadToArray : "Remarks: $aArray[0] will contain the number of records read into the array".So you need to get rid of the [0] element of the array once it has been created. And before you ask, _ArrayDelete will do that for you.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
molay Posted March 10, 2009 Author Share Posted March 10, 2009 thanks Budd. Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 (edited) If you are just attempting to append the contents of one file to the existing contents then why are you playing with arrays at all? $hFile = FileOpen($masterFile, 1) FileWrite($hFile, @CRLF & FileRead($newFile)) FileClose($hFile) EDIT: Better yet, just to make sure you don't append it a dozen times while you are playing with it. If Not StringInStr(FileRead($MasterFile), FileRead($newFile)) Then $hFile = FileOpen($masterFile, 1) FileWrite($hFile, @CRLF & FileRead($newFile)) FileClose($hFile) EndIf Edited March 10, 2009 by GEOSoft 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!" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now