Thursday 29 October 2009

CMD/BAT Librarian

Introduction
Unfortunately CMD.EXE, the command line interpreter in Windows, does not allows to collect favorite scripts under appropriate folders and use them multiple times in the future. So we have to use the "copy-and-paste" technology to migrate some needed functionalities from one script to another.

The script below allows to store debugged scripts under the determined folder, use them mutiple times, compile and link automatically to the final script.

Logfile rotation by CMD/BAT

The script below allows to rotate file (e.g.: logfiles). By default, the length of rotation is 5. It means that this script rotates some file no more than for 5 times.

Let's consider the permanently growing file of some application named as something.log and we'd like to keep records in this file for the long time as much as possible. But for some reason this file is cleaning up periodically or a size of the file affects on the application's performance.

The recent records are available from the file something.log and the previously saved records are available under the name something.log.1, etc until the something.log.5. After the following rotation the content of the last file will be lost and replaced by the content of the previous file (something.log.4 will be copied to the something.log.5) and the first file something.log will be copied to the something.log.1. At the same time the something.log will be truncated.

rotate something.log 10

Sunday 4 October 2009

WHICH: UNIX-to-NT ported

WHICH is unix-world command, implemented using CMD/BAT feature only.

Friday 2 October 2009

Simple Batch Progress Bar

Example 1. Print the bar within the window with '#' as the default filling character
call :progressbar 50
Example 2. The same as above but with an another filling character
call :progressbar 50 *
Example 3. Print the bar in the window title
set progressbar_t=1
call :progressbar 50