Directory File Count

Hi all

I need to count the number of jpg files in a directory (the same directory as the file which will do the counting.)

In ASP! Can anyone do this?
LVL 1
ZorkinhimerlinglingAsked:
Who is Participating?
 
basicinstinctCommented:
This worked for me:

<%
    Dim FSO
    Dim Files
    Dim File
    Dim Count
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
    Set Files = FSO.GetFolder(Server.MapPath("./")).Files
    Set FSO = Nothing
    Count = 0
    For Each File In Files
          Select Case LCase(Right(File.Name, 3))
                Case "jpg"
                  Count = Count + 1
          End Select
    Next
    msgbox(Count)
    Set File = Nothing
    Set Files = Nothing
%>

This is based on this example:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=7522

Cheers
0
 
ZorkinhimerlinglingAuthor Commented:
Thank you. I had to replace msgbox with response.write, but it does what I need it to do.
0
 
ZorkinhimerlinglingAuthor Commented:
Sorry I should of mentioned msgbox returns a permissions denied error
0
 
basicinstinctCommented:
glad it worked zork

actually the msgbox was something i forgot to change - I actually ran it as a script on my desktop and had to change a few things to make it work as ASP - forgot to do the msgbox but i'm glad you worked it out

cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.