[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
Here's a "quick and dirty" little program to remove blank lines
from a specified input text file and write non-blank lines to a specified output file.
Addendum August 13, 2006: A viewer with hundreds of files to fix, wrote asking for a version which would allow multiple files to be selected for processing in a single run. Version 2, posted today, provides that ability. Files are selected by the standard multi-select technique; use Click and Shift-click to select a range of files, use Ctrl-click to select or deselect individual files. Options are provided to backup files before processing or to provide a new name for each file.
October 30 2011: Here is a command line version of the program which will operate from a command line or from a Windows batch file. Either one is enough trouble to set up to make one appreciate the GUI features of current Delphi and Windows versions. Nevertheless, batch files can be an easy way to repetitively run a program without user intervention. That's the case for a user who requested this batch version of ClearBlankLines. Parameters allow masked searches for files to be processed including ability to search subdirectories, and to make backups of files which are changed. Since most people, will probably not be interested in this version, I'll refer those who are to the Batch version download below. It contains a "Readme" file outlining program usage and also a sample ".bat" batch file with a couple of text files for testing. It runs OK here, but write if you find bugs or have questions, drop me an email and I'll try to help..
May 11, 2012: Version 3 of the user interactive version and Version 2 of the command line version were posted today with the added option of trimming leading blanks from lines which contain text in addition to removing entirely blank lines. .
June 11, 2012: Last month's posting triggered a number of enhancement requests from users. Version 3.1 posted today adds these features:
Note: The command mode version, now has 12 instead of the previous 3 parameters. Basic testing of the new features was completed but the chance of unintended interactions among the hundreds of possible parameter combinations has increased. The user remains solely responsible for results, so testing and retaining backups before any mass conversion is strongly recommended!
November 8, 2012: I found another reason to modify Clear Blanks recently which led to posting Version 4 today. I, along with many others, still use Delphi 7 as my first choice compiler. One of the minor irritations has been that their final Help file update included Kylix (a Delphi 7 Linux version) help items in the D7Ref.toc (table of contents) file. This typically added extra time and an extra click to look up a Windows version VCL control. But every Kylix help entry in the table of contents contains the string "[CLX]". It was simple to modify the "character select" option from the June update to find embedded strings rather than single characters to select lines to delete or keep. Presto-change-o, my Delphi help file no longer knows that Kylix ever existed! For flexibility, I also added a "Match case" check box to control whether the string searches are case sensitive.
December 22, 2012: Version 4.1 addresses a couple of small issues with both the Windows and the Command line versions of Clear Blank Lines.
Copyright © 2000-2018, Gary Darby All rights reserved.