Have you ever found yourself wondering how many ASP pages are on your Web site? If you run a large site, chances are there are more than you realize! If your Web site can be updated by multiple people, chances are you have no clue as to how many ASP pages are on your site. I found myself wondering this question, along with others like:
- How many GIF files are on my site?
- What percentage of the files on my Web site are ASP pages?
- How many KBs of JPGs are on my site?
- What percentage of my Web site's hard drive space is taken up by ZIP files?
To answer these questions, I could use Windows's Find Files feature, searching for all files with
.asp extension in my Web directory, but if you aren't physically at the computer your Web site
is hosted at, this is impossible to do. You could also use InterDev or FrontPage, but you couldn't
easily determine what percentage of files were HTML files, or what percentage of the hard disk space was taken
up by ASP pages. Furthermore, if your Web site is updated frequently, recalculating these numbers by hand
can be cumbersome.
A somewhat similar article has already been written on 4Guys:
FileSystemObject for Web Site Maintenance.
In that particular article, I demonstrated how to use FSO to loop through the directories in a Web site,
checking to see if any files contain a particular extension, or are larger than a predetermined file size.
This article demonstrates how to create a reporting system that simply provides a summary of your Web site's
file system. The Using the
FileSystemObject for Web Site Maintenance
uses similar techniques to scrounge the Web site's file system, looking for files that violate a set of
acceptable and defined rules.
In order to answer these questions for myself, I created an on-line reporting system to provide a summary of
a Web site's file system. The report consists of three ASP pages. The first ASP page,
displays a summary of the Web site's file system. Specifically, it addresses how many files of each file type
there are in the Web root directory (you can choose to have it recurse through all of the Web site's physical
paths or just traverse the root directory through a checkbox on the report). It shows the percentages of
each file type, as well as how many bytes or kilobytes files with the particular extension consume on the
Web server. To the right you can see a snapshot of
Note that each file type in the table on the report contains a hyperlink. Clicking the hyperlink will take
the user to
DetailedReport.asp, which, for the files that contain that particular extension,
lists the physical and includes a link to view the file's source code. We'll discuss
DetailedReport.asp later in the article.
ExamineWeb.asp report also contains two bar graphs, generated on the fly using ASP and HTML tables. I won't be discussing
how to create the bar graphs in detail. There is already a great article on 4Guys that describes how to create
static and dynamic bar graphs using HTML and ASP:
Making Bar Charts Using ASP. The first graph, shown below, shows how the
various extensions are represented on the Web site.
Let's start looking at the source code for
ExamineWeb.asp. The work horse of the report is a
TraverseFolder. This function is defined by the following prototype:
objFolder is the Folder object through which the function should traverse through.
objDict is a dictionary object, containing information on the extensions of the files in the
Web site. Initially,
objDict is empty. As the function steps through the contents of the
folder specified by
objFolder, items are added to the
objDict dictionary, with
the extension as the key, and the number of times the extension has been found as the value.
objSizeDict is identical to
objDict except for that
value is the total number of bytes a particular file extension has consumed on the Web server. Finally,
bolRecurseDirectories is a boolean value that indicates whether or not the user would like the
report to recurse all of the Web site's directories or just search the root directory.
In Part 2 we'll look at the complete source code for