Command-Line Utilities

CyLog Software has a long tradition in writing command-line tools. Everything started ages ago on CP/M, then MS-DOS. Our most famous command-line utility L.EXE was the subject of much attention in the era of BBSs and FidoNet (early 90s). Whist we are now mostly develop for Windows operating systems, some tools have survived the mouse-based interfaces and are available to download for free on this page.
Nowadays our command-line utilities run on Windows command prompt and they have a variety of uses:

  • clDisks, conveniently measure the total and free size of your disks
  • clTimer, measure the timer it takes to run a program or a batch job
  • CountLn, a recursive line counter for text files
  • ExitCode, returns the specified exit code and assists with batch file programming
  • P4Rev, display RCS style tags from source code files, recursivelly collected from directories. Supports Perforce, PVCS, CVS, Subversion tags.
  • ReplaceStr, a console filter that replaces text (includes support for regular expressions)
  • ReplaceTxt, powerful template engine for variable substitution in text files
  • Sleep, pause the execution of a batch file for the specified time in milliseconds
  • Wo, find files in your PATH directories (similar to Unix "which" command)

clDisks v1.01

clDisks is a very simple utility that displays the free and total size of your hard disks. By default it will display the sizes of all your fixed disks and the full totals. You can specify a string of drive letters on the command line to restrict the list of drives displayed.
Usage:

  clDisks [<drive letters>]

  e.g.: clDisks
        clDisks cdef

Example Run:

C:\>clDisks cjm

clDisks v1.02 ©2006-2008 CyLog Software

------------------------------------------------------------------------------
Drive:         Bytes Free        Bytes Total  MBytes Free MBytes Total Free(%)
------------------------------------------------------------------------------
C:         14,813,052,928     62,915,133,440       14,127       60,001  23.54%
J:         10,537,340,928     16,779,538,432       10,049       16,002  62.80%
M:         13,594,578,944     67,110,023,168       12,965       64,001  20.26%
------------------------------------------------------------------------------
Total:     38,944,972,800    146,804,695,040       37,141      140,004  26.53%
------------------------------------------------------------------------------

clTimer v1.01

clTimer is a utility that measures the execution time of a batch job or command. You can use it in a batch file to start and stop a timer, before and after a set of commands. For more "immediate" measurements you can just supply a command line which will be executed as a child process.
Usage:

clTimer [-start|-stop|-clear|-C"command line"]

-start   starts the timer (writes the current Windows Tick count to the registry)
-stop    stops the timer (displays the time passed since "-start"  was executed.
         You can run -stop multiple times, to display lap times.
-clear   removes the timer entries from the registry
-C"..."  execute the command-line and display the execution time

CountLn v1.03

CountLn is a Win32 utility that counts lines in text files. It supports all types of text files (DOS/Windows, Unix, Mac) by detecting all types of End-Of-Line delimiters (CR-LF for DOS/Windows, LF for Unix and CR for Mac). Usage:

countln <wildcard> [/s]
  /s recurses directories

Example run:

M:\example>countln *.pas

CountLn v1.03 ©2003-2007 CyLog Software

Changing dir to :
UBitmapFilters.pas          11148 bytes, [  289  289  289] :  289 lines
UCopyFiles.pas               1289 bytes, [   54   54   54] :   54 lines
...
UTIconShortcut.pas          22747 bytes, [  600  600  600] :  600 lines
UToolboxFactory.pas          7907 bytes, [  158  158  158] :  158 lines

Found 8,915 lines in 21 files (1 folders). Total size 322,249 bytes

ExitCode v1.01

ExitCode is a utility that can be used for programming and debugging batch files. It simply executes and returns immediatelly with the exit code that you specify in the command-line.
Use ExitCode for conveniently returning codes that help you handle special cases in your batch files.
ExitCode displays a few diagnostic elements of the command's execution as shown in the examples below:

C:\>exitcode
ExitCode v1.01 ©2007-2008 by CyLog Software

Current Directory : C:\
Command line      : exitcode
Cmd Line Param  0 : c:\winutil\exitcode.exe
Exiting with code : 0

C:\>exitcode 123
ExitCode v1.01 ©2007-2008 by CyLog Software

Current Directory : C:\
Command line      : exitcode 123
Cmd Line Param  0 : c:\winutil\exitcode.exe
Cmd Line Param  1 : 123
Exiting with code : 123

P4Rev and PVCSRev v1.40

P4Rev displays RCS Revision Numbers of source code files as injected by Perforce, PVCS or other RCS compilant source control systems. Usage:

 p4rev [-?] [-s] [-r] [-fp] [<wildcard>]

Examples:
    p4rev -?     // display this help
    p4rev *.sql  // display revision numbers of all *.sql files in current folder
    p4rev -s     // display revision numbers of all files under current folder
                    and child-folders
    p4rev -r     // display revision numbers only of all files in current folder
    p4rev -fp    // use full paths as headers of file lists

ReplaceStr v1.12

ReplaceStr is a console filter (Uses console standard Input and Output) that replaces a string with another string. Very useful when you want to parse a text file and replace strings in it.
The latest version supports

Usage:

ReplaceStr [-l|-u|-r] <string_to_find>
           [<string_to_replace_with>|-t{<date format>}]

    -l converts input to lower case
    -u converts input to UPPER case

    -r uses Regular Expressions

    * Use "-t{date format}" as a replacement to paste current time and date info.
       For date format use:
         dd for day, mm for month, yyyy for year
         hh for hour, nn for minute, ss for seconds, zz for milliseconds
    * Enclose chars in single quotes to include them as they are
    * Note that if string contains spaces they should be quoted with double quotes

Examples:
    replacestr "this" "that"
        replaces string "this" in the standard input with "that"
    replacestr "$datetime$" "-t{yyyy-dd-mm hh:mm}"
        replaces string "$datetime$" in the standard input with the current timestamp
        using "yyyy-mm-dd hh:mm" as a format string

ReplaceTxt v1.27

ReplaceTxt is a powerful utility that can generate text file based on a variable replacement template engine. ReplaceTxt can load variable values from definition files (e.g. java-style ".properties" files) and environment variables and can be used to produce output files from a given template.

Usage (input and output text files):

ReplaceTxt <input_file> <output_file>
           [-Ddefinition=<definition_file> [-D...]]
           [-Eprefix]
           [-nodate] [-debug] [-quiet] [-test]

...or... (immediate command-line execution)

ReplaceTxt -C"command line with arguments"
           [-Ddefinition=<definition_file> [-D...]]
           [-Eprefix]
           [-nodate] [-debug] [-quiet] [-test]

The first command above will generate the <output_file> using the <input_file> as the source and will replace any string matching ${definition.key} to its value taken from <definition_file>. The second command will replace ${...} placeholders on the passed command line, then it will execute the parsed command as a child process it. The OS exitcode of the child process will be returned as the exit code of ReplaceTxt.

ReplaceTxt will also replace strings matching ${dt[+/-n]:<dateformat>} (e.g. ${dt:dd/mm/yyyy}) to the current date formatted as described in the <dateformat> string. Use +/-n to adjust current date in days (e.g. ${dt-7:dd/mm/yyyy} is a week before today). Accepted date formats are:

d, dd, ddd, dddd, ddddd, dddddd  Different representations of Current Day
m, mm, mmm, mmmm                 Current Month
yy, yyyy                         Current Year
h, hh, n, nn, s, ss, z, zzz      Hours, Minutes, Seconds, Milliseconds
t, tt                            Time in Short and Long format
am/pm, a/p, ampm                 am or pm for 12-hour clock display
e                                ISO day of week
f, ff, fff                       ISO day of year
w, ww                            ISO week of year (1=Monday, 7=Sunday)
ii, iiii                         ISO year for ISO week
'xxxx'                           Text enclosed in quotes is displayed as is

Command-line options:

-D : Definition files should have "key=value" pairs in each line, similar to
     Java-style .properties files

-E : Use -E to load environment variables using the prefix. Variables in templates
     should be referred to as: "prefix.env_var_name", e.g. -Eenv will match
     "env.username" to the logged on user.
     NOTE!!! Environment variable names will be converted to lowercase when loaded!

-C : Use -C to parse and execute a command-line instead of using input and
     output files. This is useful when you need to parameterize a cmd line in a
     batch file and replace values on it with values found in definition files.

-nodate Do not replace current date in place of ${dt:<dateformat>}
-debug  Debug Mode On
-quiet  Quiet Mode - No console output
-test   Test Mode to check the definition configuration - no replacements are made

To shorten the length of the ReplaceTxt command line you may alternatively set the environment variable REPLACETXT to a comma-separated list of definitions using the following syntax:

 SET REPLACETXT=-Eprefix;-Ddefinition=file;-Ddef2=file2.txt;...

Examples:

replacetxt input.txt output.txt -Ddef=file1.txt -Ddef2=file2.txt -Eenv

replacetxt -C"sqlplus scott/${password.scott}@ora001 @script.sql"

Another, more real-world example is to create a zip file that contains the current date and time in its filename, e.g. myzip_20081104_1823.zip:

replacetxt -C"7z a myzip_${dt:yyyymmdd_hhnn}.zip ...files..."

Sleep v1.00

Sleep is a very simple command that will allow you to put a delay in your batch files. Specify the amount of milliseconds as a parameter and Sleep will wait for that period of time. Extremelly useful in batch file programming.
Usage:

  Sleep <number of milliseconds>

Example Run:

C:\>sleep 1000

C:\>

Wo v3.00

Wo is one of those utilities that was very popular under DOS. The Windows version contains a very small part of the functionality the original wo.exe did, which was a fully capable file finder. This version for Windows enables you to find files in directories listed in your system's PATH environment variable, using the order they are specified. This way you can identify which version of a file is executed or loaded when you type its name on the command-line.
Usage:

  wo <wildcard>

  e.g.: wo win*.dll

Example Run:

C:\>wo java.exe

Wo v3.00, written by Kostas Symeonidis ©2004 CyLog Software

Searching...
J:\bea81\jdk142_05\bin\java.exe
J:\jdk150_04\bin\java.exe
C:\WINDOWS\system32\java.exe

3 file(s) found

C:\>