Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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?
0
Zorkinhimerlingling
Asked:
Zorkinhimerlingling
  • 2
  • 2
1 Solution
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now