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]

Y|M|D|H|N|S
Timestamp should specify only:
Y
Only the year (YY)
M
Year and month (YYMM)
D
Year, month and day (YYMMDD)
H
Year, month, day and hours (YYMMDDHH)
N
Year, month, day, hours and minutes (YYMMDDHHMM)
S
Year, month, day, hours, minutes and seconds (YYMMDDHHMMSS)
M|C
Whether to Move or Copy the file. Make sure you have write permission if you want to move the file.
File
Full file name. Use double quotes around it if it includes any space
DestDir
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) !



[Evolution7.jpg]
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

"Format"
Where format is a string that can contain one or more of the following:
%w
width
%h
height
%p
number of pixels (WxH)
%b
file size (compressed, in bytes)
%B
image size (uncompressed, in bytes)
%k
file size (compressed, in Kb)
%K
image size (uncompressed, in Kb)
%m
filesize (compressed, in Mb)
%M
image size (uncompressed, in Mb)
%f
filename (no extension)
%x
file extension
%y
file type (png ot jpg)
%a
full pathname
%c
number of color channels (1:Greyscale, 3:RGB, 4:RGBA...)
%t
number of bits per pixel (1 to 64)
%o
format: [S]quare, [V]ertical, [H]orizontal
%i
HTML image tag <IMG SRC=filename HEIGHT=h WIDTH=w>\n"
%l
HTML link tag <A HREF=filename>filename</A>\n"
%%
% sign
FileList
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.