Tentaal Posted July 17, 2007 Share Posted July 17, 2007 Hello, Is there a function to remove all blank lines in a text file? I was trying this but it does not work : $ReplacedString = _ReplaceStringInFile($filename,"",CHR(008)) :-) Thanks ! Link to comment Share on other sites More sharing options...
poisonkiller Posted July 17, 2007 Share Posted July 17, 2007 #include <File.au3> $file = FileOpenDialog("Open...", @DesktopDir, "Text files (*.txt)") $lines = _FileCountLines($file) $buffer = "" For $i = 1 to $lines $line = FileReadLine($file, $i) If $line <> "" Then $buffer &= $line & @CRLF EndIf Next FileDelete($file) FileWrite($file, $buffer) Link to comment Share on other sites More sharing options...
Tentaal Posted July 17, 2007 Author Share Posted July 17, 2007 Well, here you delete the file and recreate it without blank line. It's a solution, but what if I dont want to delete the file? Link to comment Share on other sites More sharing options...
poisonkiller Posted July 17, 2007 Share Posted July 17, 2007 You could replace it with FileMove... 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