Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

counting lines

  • 04-04-2000 8:34am
    #1
    Closed Accounts Posts: 577 ✭✭✭


    Anyone knows how to count the numer of lines in a file in Windows or count the number of lines in files in multiple directories? Is there a program I can use or a script I can download somewhere?


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    I think GREP does it. Can't remember.

    Here's VB script (writing it off the top of my head, so if it doesn't work, fix it)..
    filespec = "*.txt"
    f = dir(filespec)
    grandtotal = 0
    do while f <> ""
       filetotal = 0 
       open f for input as #1
       do while not eof(1)
          line input #1, buffer
          filetotal = filetotal +1
       loop
       close #1
       print f;" = "; filetotal; " Lines"
       grandtotal = grandtotal + filetotal
       f = dir
    loop
    print "Grand Total :"; grandtotal
    


    [This message has been edited by Hobbes (edited 04-04-2000).]


  • Moderators, Social & Fun Moderators Posts: 28,633 Mod ✭✭✭✭Shiminay


    Simple solution:-
    1) copy all the code.
    2) fire up Word
    3) use the line counter in Word

    cool.gif



    All the best,

    Dav
    @B^)
    http://homepage.eircom.net/~davitt


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Originally posted by Kharn:

    3) use the line counter in Word


    I heard the counter is not realible in Word? Dunno if that's the word or line counter, but Word would have to have linewrap disabled or something to give a valid count I would assume.


  • Closed Accounts Posts: 577 ✭✭✭Chubby


    Doh, didn't make myself clear. I need something that will count the number of lines of actual code in a c++ or j++ file while filtering out all the comments. Plus I want it to be able to count all the lines in all the files in all the subdirectories in one go. Doing it file by file when you have a few thousand files is errm, silly.


  • Subscribers Posts: 1,911 ✭✭✭Draco


    If you can get your hand on the Lex and Yacc book from O'Reilly, there's an example in that of how to do exactly that.

    Draco


  • Advertisement
  • Closed Accounts Posts: 577 ✭✭✭Chubby


    Found a utility that does the job. Knew there are little programs that can do it already but didn't know where to or what to look for is all.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Post a link. rolleyes.gif Stops future generations hitting the same problem.


  • Closed Accounts Posts: 6,601 ✭✭✭Kali


    telnet to a unix box and use wc


  • Moderators, Social & Fun Moderators Posts: 28,633 Mod ✭✭✭✭Shiminay


    Oh ya, forgot to say that smile.gif

    The word counter is a bit suss, but the line counter is OK (any time I've used it). And yes, you'll have to disable the line wrap smile.gif

    Well spotted oh weilder of cardboard axes!



    All the best,

    Dav
    @B^)
    http://homepage.eircom.net/~davitt


  • Registered Users, Registered Users 2 Posts: 20,099 ✭✭✭✭WhiteWashMan


    lol


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Originally posted by Kharn:
    Well spotted oh weilder of cardboard axes!

    That's tinfoil and cardboard axe. tongue.gif So watch it or my lvl 20 fisherman will come over and kick your azz.



  • Moderators, Social & Fun Moderators Posts: 28,633 Mod ✭✭✭✭Shiminay


    Originally posted by Hobbes:
    So watch it or my lvl 20 fisherman will come over and kick your azz.

    What are you talking about? Have you suddnely left Boston and moved to the Aran Islands or something?



    All the best,

    Dav
    @B^)
    http://homepage.eircom.net/~davitt


  • Closed Accounts Posts: 577 ✭✭✭Chubby


    Originally posted by Hobbes:
    Post a link. rolleyes.gif Stops future generations hitting the same problem.

    Right, just go to any download site and make a search for Code Metrics. The program I found is a dos/unix util called Poor Man's Metrics. There are other programs that can count the number of lines of code and comments in C/C++/java files but this one I got is simple and does the job.


Advertisement