Question

How can I delete every n-th (4000th) char (space character) in a file (.txt or .sql) best via batch or vbs?

Was it helpful?

Solution

You need some VBScript, you can't do this with a batch file. So something like this will do it for you

option Explicit

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim fso 

Dim inFile 
Dim outFile 
Dim buffer 

set fso = CreateObject("Scripting.FileSystemObject")

Set inFile = fso.OpenTextFile("C:\testIn.txt", ForReading)
Set outFile = fso.OpenTextFile("C:\testOut.txt", ForWriting, True)

Do While Not inFile.AtEndOfStream
    buffer = inFile.Read(3999)
    outFile.Write buffer
    If Not inFile.AtEndOfStream Then
        inFile.Read (1)
    End If
Loop

inFile.Close
outFile.Close

Hope this helps :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top