Getting a list of files in a folder

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Getting a list of files in a folder

    I have a folder on the server with several thousand image files in it.

    I am using the following code to retrieve the image names associated
    with a given MLS number (this is for a real estate web site):

    Function MlsPicList(ByVal mls)
    path = MlsPath(mls) & "*.jpg"
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    parent = fso.GetParentFolderName(path)
    Set fold = fso.GetFolder(parent)
    for each file in fold.Files
    If Left(file.name, LEN(mls)) = mls Then
    pic = MlsPicture(Left(file.name, Len(file.name) - 4), area)
    temp = temp & "," & Chr(34) & pic & Chr(34)
    End If
    next
    MlsPicList = Mid(temp, 2)
    set fold = nothing
    set fso = nothing
    End Function

    Since I can't specify a filespec with a wildcard, my code has to loop
    through ALL of the filenames to find those that I need.

    Beyond putting all of the filenames into an indexed database (not really
    possible, the folder is updated with new and modified images hourly), is
    there a faster way to get just the files that I need?

    --Dave
    Dave Navarro Guest

  2. Similar Questions and Discussions

    1. Help with script to list non-html files in folder
      Hi I have this code but it does not seem to list non-html files. Could anyone point me in the right direction. Thanks in advance Mark
    2. How to tell what swf files are in a folder?
      If no one knows the answer, how about a suggestion about where I might find the answer.
    3. List Files in a Web Folder
      Hi All I want to create a webpage which will list all the files in particular folder and hyperlink to them to allow users to view the grpahics...
    4. List items in a folder
      I would like to be able to list a directory (or something like it)of the contance of a certian folder. How can this be done on a web page? TIA Jim
    5. Print folder list
      Hi Charles, See: HOW TO: Add "Print Directory" Feature for Folders in Windows XP http://support.microsoft.com/?kbid=321379 -- Best of...
  3. #2

    Default Re: Getting a list of files in a folder

    "Dave Navarro" <dave@dave.dave> wrote in message
    news:MPG.19f804812bd590e989763@news-40.giganews.com...
    > Beyond putting all of the filenames into an indexed database (not really
    > possible, the folder is updated with new and modified images hourly), is
    > there a faster way to get just the files that I need?
    Here is an approach that might seem a little odd, but it could work.

    Say as a once-every-ten-minute scheduled job on the server - toss the name
    of every file into an XML document that looks like the ADODB AdPersistXML
    format. Then, when your ASP page calls this function, open the adPersistXML
    document as an ADODB.Recordset and use the recordset's "Find" method to
    narrow your criteria.

    R.



    Richard K Bethell Guest

  4. #3

    Default Re: Getting a list of files in a folder

    Hi Dave,

    See this post and replies for some other suggestions.
    nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl

    Ray at work

    "Dave Navarro" <dave@dave.dave> wrote in message
    news:MPG.19f804812bd590e989763@news-40.giganews.com...
    > I have a folder on the server with several thousand image files in it.
    >
    > I am using the following code to retrieve the image names associated
    > with a given MLS number (this is for a real estate web site):
    >
    > Function MlsPicList(ByVal mls)
    > path = MlsPath(mls) & "*.jpg"
    > Dim fso
    > Set fso = CreateObject("Scripting.FileSystemObject")
    > parent = fso.GetParentFolderName(path)
    > Set fold = fso.GetFolder(parent)
    > for each file in fold.Files
    > If Left(file.name, LEN(mls)) = mls Then
    > pic = MlsPicture(Left(file.name, Len(file.name) - 4), area)
    > temp = temp & "," & Chr(34) & pic & Chr(34)
    > End If
    > next
    > MlsPicList = Mid(temp, 2)
    > set fold = nothing
    > set fso = nothing
    > End Function
    >
    > Since I can't specify a filespec with a wildcard, my code has to loop
    > through ALL of the filenames to find those that I need.
    >
    > Beyond putting all of the filenames into an indexed database (not really
    > possible, the folder is updated with new and modified images hourly), is
    > there a faster way to get just the files that I need?
    >
    > --Dave

    Ray at Guest

  5. #4

    Default Re: Getting a list of files in a folder

    Hehe,

    Ray I was going to point him to this thread =)

    --
    Thanks from this ASP Newbie
    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:ejilcc%23kDHA.2444@TK2MSFTNGP09.phx.gbl...
    > Hi Dave,
    >
    > See this post and replies for some other suggestions.
    >
    nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl
    >
    > Ray at work
    >
    > "Dave Navarro" <dave@dave.dave> wrote in message
    > news:MPG.19f804812bd590e989763@news-40.giganews.com...
    > > I have a folder on the server with several thousand image files in it.
    > >
    > > I am using the following code to retrieve the image names associated
    > > with a given MLS number (this is for a real estate web site):
    > >
    > > Function MlsPicList(ByVal mls)
    > > path = MlsPath(mls) & "*.jpg"
    > > Dim fso
    > > Set fso = CreateObject("Scripting.FileSystemObject")
    > > parent = fso.GetParentFolderName(path)
    > > Set fold = fso.GetFolder(parent)
    > > for each file in fold.Files
    > > If Left(file.name, LEN(mls)) = mls Then
    > > pic = MlsPicture(Left(file.name, Len(file.name) - 4), area)
    > > temp = temp & "," & Chr(34) & pic & Chr(34)
    > > End If
    > > next
    > > MlsPicList = Mid(temp, 2)
    > > set fold = nothing
    > > set fso = nothing
    > > End Function
    > >
    > > Since I can't specify a filespec with a wildcard, my code has to loop
    > > through ALL of the filenames to find those that I need.
    > >
    > > Beyond putting all of the filenames into an indexed database (not really
    > > possible, the folder is updated with new and modified images hourly), is
    > > there a faster way to get just the files that I need?
    > >
    > > --Dave
    >
    >

    David P. Jessup Guest

  6. #5

    Default Re: Getting a list of files in a folder

    I thought it was you with a fake name at first. ;] I wonder if that link
    will even do him any good though. I'm beta testing the nntp links directly
    to article IDs. I don't think that's ideal though, since (at least in my
    newsreader) there is no, "next message in this thread" button...

    Ray at work

    "David P. Jessup" <davidATimntDASHtechDOTcom> wrote in message
    news:eQVy75%23kDHA.2140@TK2MSFTNGP09.phx.gbl...
    > Hehe,
    >
    > Ray I was going to point him to this thread =)
    >
    > --
    > Thanks from this ASP Newbie
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:ejilcc%23kDHA.2444@TK2MSFTNGP09.phx.gbl...
    > > Hi Dave,
    > >
    > > See this post and replies for some other suggestions.
    > >
    >
    nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl
    > >

    Ray at Guest

  7. #6

    Default Re: Getting a list of files in a folder

    Heh,

    Yeah, just noticed his name is "Dave". Well I'm David and this isn't me
    posting trying to get a different question. =)

    --
    Thanks from this ASP Newbie
    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:eXlfIA$kDHA.3732@tk2msftngp13.phx.gbl...
    > I thought it was you with a fake name at first. ;] I wonder if that link
    > will even do him any good though. I'm beta testing the nntp links
    directly
    > to article IDs. I don't think that's ideal though, since (at least in my
    > newsreader) there is no, "next message in this thread" button...
    >
    > Ray at work
    >
    > "David P. Jessup" <davidATimntDASHtechDOTcom> wrote in message
    > news:eQVy75%23kDHA.2140@TK2MSFTNGP09.phx.gbl...
    > > Hehe,
    > >
    > > Ray I was going to point him to this thread =)
    > >
    > > --
    > > Thanks from this ASP Newbie
    > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > > news:ejilcc%23kDHA.2444@TK2MSFTNGP09.phx.gbl...
    > > > Hi Dave,
    > > >
    > > > See this post and replies for some other suggestions.
    > > >
    > >
    >
    nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl
    > > >
    >
    >

    David P. Jessup Guest

  8. #7

    Default Re: Getting a list of files in a folder

    The referenced example works for me only when run as a local *.vbs file. Run
    as *.asp on a server always returns 0 files with the same pattern and UNC
    location. Is this caused by a security issue?

    thanks
    LJB

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:ejilcc%23kDHA.2444@TK2MSFTNGP09.phx.gbl...
    > Hi Dave,
    >
    > See this post and replies for some other suggestions.
    >
    nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl
    >
    > Ray at work

    ljb Guest

  9. #8

    Default Re: Getting a list of files in a folder

    My news reader doesn't even like the URL, says it's invalid. Agent
    1.5/32.451

    Jeff

    On Thu, 16 Oct 2003 10:16:01 -0400, "Ray at <%=sLocation%>"
    <myfirstname at lane34 dot com> wrote:
    >I thought it was you with a fake name at first. ;] I wonder if that link
    >will even do him any good though. I'm beta testing the nntp links directly
    >to article IDs. I don't think that's ideal though, since (at least in my
    >newsreader) there is no, "next message in this thread" button...
    >
    >Ray at work
    >
    >"David P. Jessup" <davidATimntDASHtechDOTcom> wrote in message
    >news:eQVy75%23kDHA.2140@TK2MSFTNGP09.phx.gbl...
    >> Hehe,
    >>
    >> Ray I was going to point him to this thread =)
    >>
    >> --
    >> Thanks from this ASP Newbie
    >> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    >> news:ejilcc%23kDHA.2444@TK2MSFTNGP09.phx.gbl...
    >> > Hi Dave,
    >> >
    >> > See this post and replies for some other suggestions.
    >> >
    >>
    >nntp://msnews.microsoft.com/microsoft.public.inetserver.asp.general/#YSoD8okDHA.744@tk2msftngp13.phx.gbl
    >> >
    >
    Jeff Cochran Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139