Aaron
Sun Nov 02 12:48:14 CST 2003
This measures carriage returns and comments, not necessarily explicit lines
of code. You could loop through the split array to toss out empty lines or
comments, if you wanted to make it more sophisticated.
<%
folder = "<local folder path>" ' or server.mappath("/something/")
set fso = createobject("Scripting.FileSystemObject")
set fold = fso.getFolder(folder)
for each file in fold.files
if right(lcase(file.name), 4) = ".asp" then
set fs = fso.opentextfile(folder & file.name, 1)
lines = ubound(split(fs.readall(), vbCrLf)) + 1
response.write file.name & " : " & lines & " lines.<br>"
totalLines = totalLines + lines
fileCount = fileCount + 1
fs.close: set fs = nothing
end if
next
response.write "<p>Number of ASP files: " & fileCount
response.write "<p>Total lines in all ASP files: " & totalLines
set fold = nothing: set fso = nothing
%>
--
Aaron Bertrand, SQL Server MVP
http://www.aspfaq.com/
Please reply in the newsgroups, but if you absolutely
must reply via e-mail, please take out the TRASH.
"Rob Meade" <robb.meade@NO-SPAM.kingswoodweb.net> wrote in message
news:s47pb.3689$R96.25986231@news-text.cableinet.net...
> ...little function for count lines of code?
>
> I was going to do this a little while ago, hoping to count each line in
each
> file in each folder etc etc, and then determine whether it was say ASP,
HTML
> or comments....and give totals...
>
> Anyone got anything like this they dont mind sharing?
>
> Just curious...
>
> Regards
>
> Rob
>
>