Delete blank lines in a txt file

Page 1 of 1

1 Replies - 1112 Views - Last Post: 11 June 2014 - 07:23 AM Rate Topic: -----

#1 ApprenticeAlexH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 10-June 14

Delete blank lines in a txt file

Posted 11 June 2014 - 07:20 AM

Hi guys.

Here is my current code which deletes all text until a string is met.

want I need help with is how I can add to this code in order to remove all blank lines for every txt file within a folder?

if anyone could help would be much appreciated!!

Regards,

Alex.

_____________________________________________________________

dim fso, folder, files, contents, tempFO, index

set fso = CreateObject("Scripting.FileSystemObject")
set folder = fso.GetFolder("C:\Scripting")
set files = folder.Files

For Each file in files
set tempFO = fso.OpenTextFile(file, 1)
contents = tempFO.ReadAll()
tempFO.Close()
index = instr(contents, "REPORTS=CLUC")

If index > 0 Then
set tempFO = fso.OpenTextFile(file, 2)
tempFO.Write(Mid(contents, index))
tempFO.Close()
End if
Next

________________________________________________________________

Is This A Good Question/Topic? 0
  • +

Replies To: Delete blank lines in a txt file

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,289
  • Joined: 12-June 08

Re: Delete blank lines in a txt file

Posted 11 June 2014 - 07:23 AM

Please do not open duplicate topics. The previous one was merged in your original thread.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1