Champak Posted February 7, 2008 Posted February 7, 2008 (edited) Finding and deleting the line is not a problem, but the blank space left behind is. I really don't want to bother with writing to a second file, deleting and renaming the file. So is it possible to go through and remove the blank line like you do when looking for an actual string? Prefer, but not a must, to not bother with an array for this. #include <File.au3> $find = "Test Line" $replace = "" $filename = "C:\Test.txt" _ReplaceStringInFile($filename,$find,$replace) Edited February 7, 2008 by Champak
Champak Posted February 7, 2008 Author Posted February 7, 2008 (edited) Found a way...if someone knows a better way please post. $fileread = "testfile.txt" $lines = _FileCountLines($fileread) $hold = "" For $x = 1 to $lines $search= FileReadLine($fileread, $x) If $search <> "" Then $hold&= $search & @CRLF EndIf Next FileDelete($fileread) FileWrite($fileread, $hold) Edited February 7, 2008 by Champak
Siao Posted February 7, 2008 Posted February 7, 2008 do string replace, like here #463031 "be smart, drink your wine"
faldo Posted March 26, 2024 Posted March 26, 2024 Not sure if it depends on how the file is formatted but i managed to simplify this by: #include <File.au3> _ReplaceStringInFile(@ScriptDir&"\filewithemptylines.txt",@CRLF&@CRLF,"") Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API
Moderators JLogan3o13 Posted March 26, 2024 Moderators Posted March 26, 2024 (edited) @faldo You do realize this is almost 16 years later?! Please don't resurrect old posts. Edited March 26, 2024 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts