Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: calculate the length of all do-files in a folder, including subfolders
From
Eric Booth <[email protected]>
To
"<[email protected]>" <[email protected]>
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
[email protected]
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/