Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Eric Booth <ebooth@ppri.tamu.edu> |

To |
"<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: calculate the length of all do-files in a folder, including subfolders |

Date |
Tue, 21 Jun 2011 19:50:44 +0000 |

<> You could use `r(lnum)' stored by -hexdump- to get the number of lines. Here's a way to loop over all .do files in a directory and count up the # of lines: ((be sure to replace <yourfolderhere> with your folder path (e.g. "C:\myfolder" or "/users/me/documents//")) ***********! global files: dir "<yourfolderhere>" files "*.do", nofail respectcase di `"$files"' loc tot = 0 foreach f in $files { qui hexdump "<yourfolderhere>`f'", results di in r "`f': `r(lnum)'" loc tot = `tot' + `r(lnum)' } di "`tot'" //this contains the overall total ***********! - Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu On Jun 21, 2011, at 1:42 PM, Dimitriy V. Masterov wrote: > I need to calculate how many lines of code were written for a > particular project. The do-files are in various nested subdirectories > of a single folder on a Windows 7 machine. Is there a way to avoid the > tedium of doing this by hand? > > DVM > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: calculate the length of all do-files in a folder, including subfolders***From:*Eric Booth <ebooth@ppri.tamu.edu>

**References**:**st: calculate the length of all do-files in a folder, including subfolders***From:*"Dimitriy V. Masterov" <dvmaster@gmail.com>

- Prev by Date:
**RE: st: mean group** - Next by Date:
**Re: st: calculate the length of all do-files in a folder, including subfolders** - Previous by thread:
**st: calculate the length of all do-files in a folder, including subfolders** - Next by thread:
**Re: st: calculate the length of all do-files in a folder, including subfolders** - Index(es):