CLP – Command Line Text File List Program

I’ve decided to post some of the useful small programs I’ve written for my own use.

CLP is a simple C# console program that lists text files on a Windows printer. It was originally intended to list C source code, but it is useful for printing many kinds of text files. Yes you can use Notepad for this but CLP has some useful differences and additional features:

1. As a command line program that takes a filename as an argument, you can put it in your SendTo list and thus be able to print text files from a right-click.

2. CLP puts a header in bold on each page with the filename, the file date and time (not the current date), and the page number.

3. Output is in a fixed-pitch font, which makes outputting things like tables easy.

4. Printed lines are 80 characters long. Continuation lines are used for lines that are too long. Continuations are marked with bullet characters to make it clearer that they are continuations.

5. Output is to any Windows printer. A CLP default printer selection is maintained, with the ability to list available printers and select a new default from the command line.

6. Multiple files can be specified and files to list can be specified with wildcards or through the use of a file containing a list of filenames.

7. Operating instructions can be displayed by simply entering the program name with no arguments. The resulting output looks like this:

clp default printer: HL-5250DN 2-sided

clp - print file(s) to clp default printer - 12/25/16 (.NET)

To execute enter: clp [namfl1...namfln] [-p[n]] [-1|-2]

where each namfl is a file to print namfls can use paths and wildcards an @namfl prints files named in namfl.nms namfl.nms entries can use paths namfl.nms entries cannot use wildcards or @namfls
-1 simples (driver default is ignored)
-2 duplex (driver default is ignored) -p lists available printers by number -pn selects clp default printer n printer selections are saved between runs (clp has its own default printer)

The program is written in C# using the .NET library. Here is a zip file containing the latest source and executable files:



Version 4/12/19: The program was updated to allow parameters to specify 1-sided or 2-sided output, overriding the driver default. These are especially useful if using CLP with SendTo: create “CLP 1-sided” and “CLP 2-sided” links in the SendTo folder.

Version 10/19/20: Fixed a bug that caused pages to be printed in landscape orientation if the printer driver was defaulting to that. Changed to force use of Portrait orientation.

Version 11/10/20: Fixed a related bug that caused duplex pages to flip horizontally rather than vertically.

Version 12/23/23: Fixed a bug that caused it to fail if the CLP default printer name was not a valid Windows printer name. This could happen if you rename a printer.

Leave a Reply

Your email address will not be published. Required fields are marked *