Count Lines in Pages

Contents of Page: CountPageLines.asp Number of Lines: 155 Last Modified: 2/20/2026 1:43:18 PM
0001: <% @Language = "VBScript" %>
0002: 
0003: <!-- #include FILE="include/adovbs.inc" -->
0004: <!-- #include FILE="include/constants.inc" -->
0005: <!-- #include FILE="include/funcs.asp" -->
0006: <!-- #include FILE="include/ReturnPageSet.inc" -->
0007: 
0008: <%
0009: 
0010: 	folder = Request.QueryString("folder")
0011: 	If folder = "" Then
0012: 	folder = "/"
0013: 	Else
0014: 	folder = "/" & folder & "/"
0015: 	End If
0016: 	Columns = Request.QueryString("Columns")
0017: 	
0018: 	If Columns = "" Then Columns = 5
0019: 	
0020: 	CellWidth = 100 / Columns
0021: 	
0022: 	NameWidth = Cint(CellWidth * .8)
0023: 	LinesWidth = Cint(CellWidth *.2)
0024: 	
0025: 	Columns = Cint(Columns)
0026: 	
0027: 	Website = Request.ServerVariables("HTTP_HOST")
0028: 	
0029: %>
0030: 
0031: 
0032: <html>
0033: 
0034: <head>
0035: 	<title>Count Lines in Pages</title>
0036: 	<link href="mm.css" rel="stylesheet" type="text/css">
0037: 	<link href="desb.css" rel="stylesheet" type="text/css">	
0038: <meta name="viewport" content="width=device-width">
0039: 
0040: 
0041: </head>
0042: <table cellspacing="1" border="0" cellpadding="5" width="80%" height="53">
0043: <tr>
0044:       
0045:       <td class="norm" colspan="10" align="center"><br><input type="button" class="button_close" value="Close Window" class="norm" onclick="window.close()"></td></td>
0046:  </tr>		
0047: 
0048: </table>
0049: <table cellspacing="1" border="1" cellpadding="5" width="80%" height="53">
0050: <tr height="35">
0051: <td class="norm" colspan="10" align="center"><big><big>Pages and number of lines for *.asp files for WebSite: <b><%= WebSite %>/mm</b></td>
0052: </tr>
0053: 
0054: 
0055: 
0056: 
0057: <%
0058: 
0059: 
0060: Kount = 0
0061: 
0062: bgcolor="#D8D8D8"
0063: 
0064: bgcolor="#ffffff"
0065: 
0066: Dim fso, folder, file, ts
0067: Dim folderPath, lineCount, totalLines
0068: 
0069: folderPath = Server.MapPath("/mm/")  ' change this
0070: 
0071: 
0072: 
0073: Set fso = Server.CreateObject("Scripting.FileSystemObject")
0074: Set folder = fso.GetFolder(folderPath)
0075: 
0076: totalLines = 0
0077: FileCount = 0
0078: 
0079: 
0080: %>
0081: 
0082: <tr>
0083: 
0084: <% 
0085: 
0086: For Each file In folder.Files
0087: 
0088: 
0089: 
0090:     ' Only process text-based files (optional filter)
0091:     If LCase(fso.GetExtensionName(file.Name)) = "asp" OR LCase(fso.GetExtensionName(file.Name)) = "css" or 1 = 1 Then
0092: 		
0093: 		FileCount = FileCount + 1
0094: 	
0095: 
0096: If bgcolor="#D8D8D8" Then
0097: 
0098: bgcolor="#ffffff"
0099: 
0100: Else
0101: 
0102: bgcolor="#D8D8D8"
0103: 
0104: End If
0105: 
0106: 
0107:         lineCount = 0
0108:         Set ts = file.OpenAsTextStream(1) ' ForReading
0109: 
0110:         Do Until ts.AtEndOfStream
0111:             ts.ReadLine
0112:             lineCount = lineCount + 1
0113:         Loop
0114: 
0115:         ts.Close
0116:         Set ts = Nothing
0117: 
0118:         totalLines = totalLines + lineCount
0119: 
0120: Kount = Kount + 1
0121: 			
0122: %>
0123: <td class="norm" width="<%= NameWidth %>%" bgcolor="<%= bgcolor %>"><big>
0124: <a href="displaypagecontents.asp?PageName=<%= file.Name %>&Lines=<%= lineCount %>" target="_blank"><%= file.name %></a>
0125: 
0126: </td>
0127: <td class="norm" align="right" width="<%= LinesWidth %>%" bgcolor="<%= bgcolor %>"><b><%= lineCount %></td>
0128: <%
0129: 
0130: If Kount = Columns Then	
0131: Kount = 0
0132: 
0133: %>
0134: </tr><tr>
0135: 
0136: <% End If 
0137: 
0138:     End If
0139: 
0140: Next
0141: 
0142: 
0143: Set folder = Nothing
0144: Set fso = Nothing
0145: 
0146: totalLines = FormatNumber(totalLines, 0)
0147: 
0148: %>
0149: 
0150: </tr>
0151: <tr>
0152: <td colspan="20" class="norm" align="center"><big><big>Total Number of Pages: <b><%= fileCount %></b>&nbsp;&nbsp;&nbsp;&nbsp;Total Number of Lines:<b> <%= totalLines %><b></td>
0153: </tr>
0154: 
0155: </table>