top of page

Winbatch


I've posted quite few batch commands to this site in the past, including the very first Tip of the Night on April 10, 2015, which showed how to use the DOS batch command dir to get a list of files in a folder.

WinBatch is a scripting language that uses DOS batch commands with the Basic and C scripting languages. There is a WinBatch tech database in which you can find scripts to accomplish a variety of common tasks, and a trial version of WinBatch Navigator can be downloaded for free here, http://www.winbatch.com/download.html .

So if you open WinBatch Navigator and click on the WinBatch Studio utility, a script editor will open. You can copy scripts from the tech database, enter them in the editor and then save them as files with a .wbt extension.

A script such as this one:

;Count lines in a file - one way anyway fn="C:\test\filename.txt" count=0 handle=FileOpen(fn,"READ") While @TRUE line=FileRead(handle) If line=="*EOF*" Break Else count=count+1 EndIf EndWhile FileClose(handle) Message("Lines in the file",count)

. . . will count the number of lines in text file listed on the second line.

So for this text file:

. . . we get this result:


bottom of page