Jump to content

Delete blank/empty line without writing to second file


Champak
 Share

Recommended Posts

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 by Champak
Link to comment
Share on other sites

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 by Champak
Link to comment
Share on other sites

  • 16 years later...
  • Moderators
Posted (edited)

@faldo You do realize this is almost 16 years later?! Please don't resurrect old posts.

Edited 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!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...