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 developing 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:

  • ask, ask for user input and set environment variable or pipe it to stdout
  • 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)

ask v1.00

ASK asks for user input and can then write it to the stdout or set the entered value to an environment variable and execute a command. ASK is a hybrid utility that gives you both a command-line interface and a Win32 pop-up dialog box.

ASK {mode of operation} {options}

    mode of operation := [-o]|[-v:{variable_name} -e:{cmdline}]
    options           := [-c] [-h] [-p:{prompt}]

    -o      print the user input to standard output
    -v:...  set the value of specified env var and execute the supplied cmdline
    -e:...  execute this cmdline after setting the environment variable

    -c      run in console mode, do not open a GUI dialog box
    -h      hide user input (i.e. "password" mode)
    -p:...  display the specified prompt
    1. Open a window, get user input and print it out on the console
       ASK -o
    2. Open a window, get user input and output it to file test.txt
       ASK -o > test.txt
    3. In console mode, get the value for the JAVA_HOME variable,
       then execute the command line after replacing the string
       ${JAVA_HOME} with the actual user input
       ASK -c -v:JAVA_HOME -e:"${JAVA_HOME}\bin\java -version"

The Win32 environment has a lot of restrictions in terms of altering the environment of a process. As a rule of thumb a process has the ability to change its own environment, or execute a child process with a specific environment. There is no way for a process to change its parent's environment and make a subsequent program execution use it.
ASK uses the option of setting the value of an environment variable and then executing a child process with an altered environment, i.e. ASK's own environment with the modified or added variable. Please also note that this is the reason for using ${...} replacements on the command-line as any %...% values will be replaced on the command line with existing environment settings before ASK is launched!

Example Run:
Note the value of the JAVA_HOME environment variable before and after the execution of ASK. During the execution itself the value of JAVA_HOME equals "j:\jdk160_06"

j:\>set java_home

j:\>ASK -c -v:JAVA_HOME -e:"${JAVA_HOME}\bin\java -version"

ASK v1.00 ©2008 CyLog Software

Enter value : j:\jdk160_06

+ Setting value for environment variable "JAVA_HOME"...
+ Creating child process "j:\jdk160_06\bin\java -version"
+ Waiting for child process to finish...

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

+ Exit code of child process is 0. Closing handles...

j:\>set java_home

clDisks v1.02

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.

  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.

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 into subdirectories

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:

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>]

    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


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

    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.28

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...]]
           [-nodate] [-debug] [-quiet] [-test]

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

ReplaceTxt -C"command line with arguments" [-nograve]
           [-Ddefinition=<definition_file> [-D...]]
           [-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.

     -nograve  By default ReplaceTxt will replace the grave quote (`) character will a double quote (")
               before executing the command line, thus giving you the option of passing quoted
               parameters to the child process. If this behaviour is not desired use the "-nograve"
               option to supress it.

-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;...


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.

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.

  Sleep <number of milliseconds>

Example Run:

C:\>sleep 1000


Wo v3.01

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.

  wo <wildcard>

  e.g.: wo win*.dll

Example Run:

C:\>wo java.exe

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


3 file(s) found