Misc command line utilities

"When Roman engineers built a bridge, they had to stand under it while the first legion marched across. If programmers today worked under similar ground rules, they might well find themselves getting much more interested in Ada !"    — Robert Dewar, President Ada Core Technologies.
On this page:

Extend numbered filenames

FileNbExtend.exe is a small utility that will rename files with number in their names by adding trailing zeros. For instance LI12.DAT to LI000012.DAT, ABC1.TXT to ABC00001.TXT... This allow you to sort them alphabetically.

This is a command line program (will work in DOS, Windows, WinNT, Win2000...), but you can drag and drop files onto its icon in windows. The converted filenames are 8.3, so obviously the original names must be 8.3 too. It will ignore longer names. You can use pipes to redirect the output, like >dest.txt.

Note: you cannot use wildcards in the command line, but you can use a DOS command like: "FOR %I IN (file*.ext) DO FileNbExtend %I".

Example of use: FileNbExtend Quote0.js Quote1.js Quote10.js Quote100.js Quote1000.js Quote0.js renamed to Quote000.js
Quote1.js renamed to Quote001.js
Quote10.js renamed to Quote010.js
Quote100.js unchanged.
Quote1000.js is not a 8.3 filename.

Download: Yes ! Yes ! Yes ! Where is it ? I want to download it now (1Mb, include CVI runtime engine, ImDim.exe and RollLog.exe) !

Logfile rotation

RollLog.exe is another command line utility that copies or moves a file and add a timestamp to the filename. I use it mainly from the Windows Task Scheduler to save a backup of log files.

Command line syntax: RollLog.exe Y|M|D|H|N|S M|C File [DestDir]

Timestamp should specify only:
Only the year (YY)
Year and month (YYMM)
Year, month and day (YYMMDD)
Year, month, day and hours (YYMMDDHH)
Year, month, day, hours and minutes (YYMMDDHHMM)
Year, month, day, hours, minutes and seconds (YYMMDDHHMMSS)
Whether to Move or Copy the file. Make sure you have write permission if you want to move the file.
Full file name. Use double quotes around it if it includes any space
Optional destination directory. If not specified the copy is done to the same directory as the source file.

Example: RollLog.exe D C C:\Inetpub\cgi-bin\counter.dat "C:\Documents and Settings\username\My Documents\Backups\WebPageStuff\AccessLog\Daily"
Will do a copy of the file counter.dat as counter_020117.dat. Note that the timestamp is added to the filename, not the extension name.

So how does one use this program ?
You call it from the task scheduler: [Start][Settings][Control Panel][Scheduled Tasks][Add Scheduled Task].
Select RollLog.exe as the program to run and then change its properties ([Run] line) to have the full command line instuction, for instance: "C:\Documents and Settings\username\My Documents\Work\StrfTime\RollLog.exe" D C C:\Inetpub\cgi-bin\counter.dat "R:\RemoteLocationThatHackersCantGet\Backups\WebPageStuff\AccessLog\Daily". Run it daily at 00:00:01 in the morning and it will create a daily backup for you...

Download: Yes ! Yes ! Yes ! Where is it ? I want to download it now (1Mb, include CVI runtime engine, ImDim.exe and FileNbExtend.exe) !

Evolution in action.

Image dimensions

ImDim.exe is command line utility that will give you various image properties, like width, height, filesize and more. You can use it to generate statistics for your images. Works only on JPEG and PNG files.

Command line syntax: ImDim "Format" FileList

Where format is a string that can contain one or more of the following:
number of pixels (WxH)
file size (compressed, in bytes)
image size (uncompressed, in bytes)
file size (compressed, in Kb)
image size (uncompressed, in Kb)
filesize (compressed, in Mb)
image size (uncompressed, in Mb)
filename (no extension)
file extension
file type (png ot jpg)
full pathname
number of color channels (1:Greyscale, 3:RGB, 4:RGBA...)
number of bits per pixel (1 to 64)
format: [S]quare, [V]ertical, [H]orizontal
HTML image tag <IMG SRC=filename HEIGHT=h WIDTH=w>\n"
HTML link tag <A HREF=filename>filename</A>\n"
% sign
List of files to checkout. Should be only PNG and JPG. Can contain DOS wildcards (i.e. '*' or '?')

Example 1: ImDim "Width:%w Height:%h %% Pixels:%p FileSize:%b/%kKb/%mMb ImgSize:%B/%KKb/%MMb %a %f %x %y #Colors:%c Bits:%t Format:%o" "C:\Photo\300\*.*" \\remote\Share\Adelie00?.png

Example 2: ImDim "<IMG SRC=""%f.%x"" ALT=""Size:%kKb"" WIDTH=%w HEIGHT=%h><BR>" *.jpg > part.html

Download: Yes ! Yes ! Yes ! Where is it ? I want to download it now (1Mb, include CVI runtime engine, FileNbExtend.exe and RollLog.exe) !

This freeware written with LabWindows/CVI.