MSF Posted May 22, 2009 Share Posted May 22, 2009 Using AutoIT; is it possible to read in a large text file and append an asterisk to the end of each record in the text file? Each record is terminated by a carriage return and line feed. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 22, 2009 Moderators Share Posted May 22, 2009 FileReadLine along with _FileWriteToLine Link to comment Share on other sites More sharing options...
MSF Posted May 22, 2009 Author Share Posted May 22, 2009 FileReadLine along with _FileWriteToLineIt's that easy? Man I love AutoIT! Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 22, 2009 Moderators Share Posted May 22, 2009 This is probably faster. #include <File.au3> Global $aArray Global $sFilePath = "C:\temp\test.txt" _FileReadToArray($sFilePath, $aArray) If @error Then ConsoleWrite("Error reading file." & @CR) Exit EndIf For $i = 0 To $aArray[0] $aArray[$i] &= "*" Next _FileWriteFromArray($sFilePath, $aArray, 1) If @error Then ConsoleWrite("Error writing file from array." & @CR) EndIf Link to comment Share on other sites More sharing options...
MSF Posted May 22, 2009 Author Share Posted May 22, 2009 (edited) This is probably faster. #include <File.au3> Global $aArray Global $sFilePath = "C:\temp\test.txt" _FileReadToArray($sFilePath, $aArray) If @error Then ConsoleWrite("Error reading file." & @CR) Exit EndIf For $i = 0 To $aArray[0] $aArray[$i] &= "*" Next _FileWriteFromArray($sFilePath, $aArray, 1) If @error Then ConsoleWrite("Error writing file from array." & @CR) EndIf Thanks! Also, These records are actually customer id's. I have a directory full of .tiff's that are named by the customer ID. How can I take all these newly edited records with the * append and put them on the same line? I would like to use this new long string of file names to write a dos batch file. I'm trying to write a dos batch script that takes ton of files and moves them to another directory. ie move 12345*.tiff, 123456*.tiff, 1234567*.tiff \newDirectory But if I can do all this without a dos batch script that would be cool! P.S. I would RTFM but I'm under a serious time crunch here. Sorry. Edited May 22, 2009 by MSF Link to comment Share on other sites More sharing options...
MSF Posted May 22, 2009 Author Share Posted May 22, 2009 Hm... Perhaps I could strip all the carriage return and line feeds from the array before writing to the file #include <File.au3> Global $aArray Global $sFilePath = "C:\temp\test.txt" _FileReadToArray($sFilePath, $aArray) If @error Then ConsoleWrite("Error reading file." & @CR) Exit EndIf For $i = 0 To $aArray[0] $aArray[$i] &= "*, " ; could I strip the @cr and @lf here? Next ; or should I strip all @cr and @lf's from $aArray? _FileWriteFromArray($sFilePath, $aArray, 1) If @error Then ConsoleWrite("Error writing file from array." & @CR) EndIf 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