Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you can't use file pointer moving tricks to change the file 'on disk' in VBScript, you'll have to re-write it. Did you test whether using .ReadAll() and .Write is 'fast enough' for you? If yes, we could discuss a way to do the modifying efficiently. First question: Do you want to delete the offending line, or should it be replaced with an empty one?</p> <p>Next Step:</p> <p>This VBScript code:</p> <pre><code> Dim goFS : Set goFS = CreateObject( "Scripting.FileSystemObject" ) Dim sDir : sDir = "..\testdata\editlargefile" Dim sSrcFSpec : sSrcFSpec = goFS.BuildPath( sDir, "lines.txt" ) Dim nLine : nLine = 5 Dim nSize : nSize = goFS.GetFile( sSrcFSpec ).Size WScript.Echo nSize, "bytes in", sSrcFSpec ReDim aHead( nLine - 2 ) Dim oTS, nIdx, sTail Set oTS = goFS.OpenTextFile( sSrcFSpec ) For nidx = 0 To UBound( aHead ) aHead( nIdx ) = oTS.ReadLine() Next oTS.ReadLine sTail = oTS.ReadAll() oTS.Close WScript.Echo Left( Join( aHead, vbCrLf ) &amp; vbCrLf &amp; vbCrLf &amp; Left( sTail, 100 ), 150 ) Set oTS = goFS.CreateTextFile( sSrcFSpec, True ) oTS.Write Join( aHead, vbCrLf ) oTS.Write vbCrLf &amp; vbCrLf oTS.Write sTail oTS.Close </code></pre> <p>output:</p> <pre><code>20888896 bytes in ..\testdata\editlargefile\lines.txt This is line 1 This is line 2 This is line 3 This is line 4 This is line 6 This is line 7 This is line 8 This is line 9 This is line 10 Thi ===================================================== xplfs.vbs: Erfolgreich beendet. (0) [11.42188 secs] </code></pre> <p>demonstrates the fastest VBScript way I can think of. The pseudo code for a language able to do file pointer tricks would be</p> <pre><code>Open the file in read+write mode Loop over the head lines to keep If Delete Skip line to delete Reset write file pointer to end of previous line Block write to file pointer till end Else Fill line to delete with spaces End Close the file </code></pre> <p>What language do you plan to use? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload