Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS (line count/record count)

Status
Not open for further replies.

babsjoy

Programmer
Sep 1, 2003
46
0
0
US
Using DOS is there a way to obtain a (line count or record count) of a .DAT file.
For example if I append two files together I would like to know the resulting total record count of appended file.

Thanks in advance...
 
Not directly - you can download cygwin. Use
Code:
wc -l filename
 
Thanks for the free download information BUT since I support a government facility we are not allowed to download unauthorized or unapproved software.
 
Try the DOS FIND command, something like:
FIND /c " " filename.ext
If you can't think of a string in every line to put inside the quotes you might try:
FIND /v /c "nonsense" filename.ext

/v = doesn't exist in line
/c = count only
 
I know this is a bit late but Win9x should have QBasic in c:\windows\command folder. If not, you can extract it from the original CD/floppy. (extraction info can be gotten at MS site -- search for QBASIC)

Since QBasic is already packaged with the installation disk(s), they should "allow" it without any ramifications--just tell them "it was always there, we just never used it because we didn't need it until now."

If it's already in the directory, you can use the simple bit of code (below) to determin the number of lines within the new file.

(working sample code...)
Code:
CLS
INPUT "enter the path & filename to count: ", FileIn$
OPEN FileIn$ FOR INPUT AS 11
PRINT
PRINT "Working";
DO WHILE NOT EOF(11)
  LINE INPUT #11, FileLine$
  MyCount = MyCount + 1
  PRINT ".";
  IF (MyCount MOD 1600) = 0 THEN PRINT : PRINT "Working";
  IF EOF(11) = 1 THEN EXIT DO
LOOP
PRINT
PRINT "Total  File  Size  : ";
PRINT LOF(11)
PRINT "Total Counted Lines: ";
PRINT MyCount
PRINT
CLOSE
INPUT "press ENTER to exit program...", Term$
END

If you encounter any difficulties, there's a forum on this site that deals with QBasic programming (just click over to forum314)

Hope this helps.
--MiggD

--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
I'd forgotten that Win95 came with QBasic. If you're running 98, you could write some VBScript which will do a similar thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top