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

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:

Recent Posts

See All

XCOPY to move and rename files

The Tip of the Night for May 8, 2018, discussed how to use XCOPY in a batch file to both copy files to a new location and rename them. Here's another approach. If this format is used, with the XCOPY

Contact Me With Your Litigation Support Questions:

  • Twitter Long Shadow

© 2015 by Sean O'Shea . Proudly created with