how to determine number of files in directory? array question

Discussion in 'ASP General' started by Bart Plessers \(artabel\), Sep 4, 2003.

  1. Hello,

    I have an asp script that lists the files in a directory:

    CurrentPATH = "c:\temp\"
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder(CurrentPATH)
    Set oFolderContents = oFolder.Files
    For Each oFileItem in oFolder.Files
    .....
    next


    However,
    before doing the "For..Next" loop, I want to determine the number of files
    in oFolderContents.

    How can I do this?
    Is there another way to determine the number of files in a given directory?

    tia

    bartp





    --
    HyperART
    Paul Van Ostaijenlaan 4
    3001 Heverlee
     
    Bart Plessers \(artabel\), Sep 4, 2003
    #1
    1. Advertising

  2. Bart Plessers \(artabel\)

    Ken Schaefer Guest

    The Files collection has a .Count() property that returns the number of
    Files in the collection;

    obj.Files.Count()

    where obj is a Folder object. Check the WSH reference, which you can
    download from here:
    http://www.microsoft.com/downloads/...48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

    Cheers
    Ken



    "Bart Plessers (artabel)" <> wrote in message
    news:...
    : Hello,
    :
    : I have an asp script that lists the files in a directory:
    :
    : CurrentPATH = "c:\temp\"
    : Set oFSO = CreateObject("Scripting.FileSystemObject")
    : Set oFolder = oFSO.GetFolder(CurrentPATH)
    : Set oFolderContents = oFolder.Files
    : For Each oFileItem in oFolder.Files
    : .....
    : next
    :
    :
    : However,
    : before doing the "For..Next" loop, I want to determine the number of files
    : in oFolderContents.
    :
    : How can I do this?
    : Is there another way to determine the number of files in a given
    directory?
    :
    : tia
    :
    : bartp
    :
    :
    :
    :
    :
    : --
    : HyperART
    : Paul Van Ostaijenlaan 4
    : 3001 Heverlee
    :
    :
    :
     
    Ken Schaefer, Sep 4, 2003
    #2
    1. Advertising

  3. Hi ken,

    thanx for quick reply.

    However, I can't get away with the syntax.
    Can you clearify a little bit?
    Maybe provide the correct syntax for my example below?

    > : CurrentPATH = "c:\temp\"
    > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    > : Set oFolderContents = oFolder.Files
    > : For Each oFileItem in oFolder.Files
    > : .....
    > : next





    tia

    bart





    --
    HyperART
    Paul Van Ostaijenlaan 4
    3001 Heverlee

    "Ken Schaefer" <> wrote in message
    news:e#...
    > The Files collection has a .Count() property that returns the number of
    > Files in the collection;
    >
    > obj.Files.Count()
    >
    > where obj is a Folder object. Check the WSH reference, which you can
    > download from here:
    >

    http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-
    8A76-1C4099D7BBB9&displaylang=en
    >
    > Cheers
    > Ken
    >
    >
    >
    > "Bart Plessers (artabel)" <> wrote in message
    > news:...
    > : Hello,
    > :
    > : I have an asp script that lists the files in a directory:
    > :
    > : CurrentPATH = "c:\temp\"
    > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    > : Set oFolderContents = oFolder.Files
    > : For Each oFileItem in oFolder.Files
    > : .....
    > : next
    > :
    > :
    > : However,
    > : before doing the "For..Next" loop, I want to determine the number of

    files
    > : in oFolderContents.
    > :
    > : How can I do this?
    > : Is there another way to determine the number of files in a given
    > directory?
    > :
    > : tia
    > :
    > : bartp
    > :
    > :
    > :
    > :
    > :
    > : --
    > : HyperART
    > : Paul Van Ostaijenlaan 4
    > : 3001 Heverlee
    > :
    > :
    > :
    >
    >
     
    Bart Plessers \(artabel\), Sep 4, 2003
    #3
  4. sorry, found it already with your VERY helpfull link!!

    syntax:
    MyCount = oFolderContents.count

    without the brackets...


    thanx a lot again

    bart



    --
    HyperART
    Paul Van Ostaijenlaan 4
    3001 Heverlee

    "Bart Plessers (artabel)" <> wrote in message
    news:#...
    > Hi ken,
    >
    > thanx for quick reply.
    >
    > However, I can't get away with the syntax.
    > Can you clearify a little bit?
    > Maybe provide the correct syntax for my example below?
    >
    > > : CurrentPATH = "c:\temp\"
    > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > : Set oFolderContents = oFolder.Files
    > > : For Each oFileItem in oFolder.Files
    > > : .....
    > > : next

    >
    >
    >
    >
    > tia
    >
    > bart
    >
    >
    >
    >
    >
    > --
    > HyperART
    > Paul Van Ostaijenlaan 4
    > 3001 Heverlee
    >
    > "Ken Schaefer" <> wrote in message
    > news:e#...
    > > The Files collection has a .Count() property that returns the number of
    > > Files in the collection;
    > >
    > > obj.Files.Count()
    > >
    > > where obj is a Folder object. Check the WSH reference, which you can
    > > download from here:
    > >

    >

    http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-
    > 8A76-1C4099D7BBB9&displaylang=en
    > >
    > > Cheers
    > > Ken
    > >
    > >
    > >
    > > "Bart Plessers (artabel)" <> wrote in message
    > > news:...
    > > : Hello,
    > > :
    > > : I have an asp script that lists the files in a directory:
    > > :
    > > : CurrentPATH = "c:\temp\"
    > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > : Set oFolderContents = oFolder.Files
    > > : For Each oFileItem in oFolder.Files
    > > : .....
    > > : next
    > > :
    > > :
    > > : However,
    > > : before doing the "For..Next" loop, I want to determine the number of

    > files
    > > : in oFolderContents.
    > > :
    > > : How can I do this?
    > > : Is there another way to determine the number of files in a given
    > > directory?
    > > :
    > > : tia
    > > :
    > > : bartp
    > > :
    > > :
    > > :
    > > :
    > > :
    > > : --
    > > : HyperART
    > > : Paul Van Ostaijenlaan 4
    > > : 3001 Heverlee
    > > :
    > > :
    > > :
    > >
    > >

    >
    >
     
    Bart Plessers \(artabel\), Sep 4, 2003
    #4
  5. Bart Plessers \(artabel\)

    Ken Schaefer Guest

    Sorry about the brackets - I was just "quoting from memory" - obviously I
    got it a little bit wrong! Glad you got it working!

    Cheers
    Ken

    "Bart Plessers (artabel)" <> wrote in message
    news:...
    : sorry, found it already with your VERY helpfull link!!
    :
    : syntax:
    : MyCount = oFolderContents.count
    :
    : without the brackets...
    :
    :
    : thanx a lot again
    :
    : bart
    :
    :
    :
    : --
    : HyperART
    : Paul Van Ostaijenlaan 4
    : 3001 Heverlee
    :
    : "Bart Plessers (artabel)" <> wrote in message
    : news:#...
    : > Hi ken,
    : >
    : > thanx for quick reply.
    : >
    : > However, I can't get away with the syntax.
    : > Can you clearify a little bit?
    : > Maybe provide the correct syntax for my example below?
    : >
    : > > : CurrentPATH = "c:\temp\"
    : > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    : > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    : > > : Set oFolderContents = oFolder.Files
    : > > : For Each oFileItem in oFolder.Files
    : > > : .....
    : > > : next
    : >
    : >
    : >
    : >
    : > tia
    : >
    : > bart
    : >
    : >
    : >
    : >
    : >
    : > --
    : > HyperART
    : > Paul Van Ostaijenlaan 4
    : > 3001 Heverlee
    : >
    : > "Ken Schaefer" <> wrote in message
    : > news:e#...
    : > > The Files collection has a .Count() property that returns the number
    of
    : > > Files in the collection;
    : > >
    : > > obj.Files.Count()
    : > >
    : > > where obj is a Folder object. Check the WSH reference, which you can
    : > > download from here:
    : > >
    : >
    :
    http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-
    : > 8A76-1C4099D7BBB9&displaylang=en
    : > >
    : > > Cheers
    : > > Ken
    : > >
    : > >
    : > >
    : > > "Bart Plessers (artabel)" <> wrote in message
    : > > news:...
    : > > : Hello,
    : > > :
    : > > : I have an asp script that lists the files in a directory:
    : > > :
    : > > : CurrentPATH = "c:\temp\"
    : > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
    : > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
    : > > : Set oFolderContents = oFolder.Files
    : > > : For Each oFileItem in oFolder.Files
    : > > : .....
    : > > : next
    : > > :
    : > > :
    : > > : However,
    : > > : before doing the "For..Next" loop, I want to determine the number of
    : > files
    : > > : in oFolderContents.
    : > > :
    : > > : How can I do this?
    : > > : Is there another way to determine the number of files in a given
    : > > directory?
    : > > :
    : > > : tia
    : > > :
    : > > : bartp
    : > > :
    : > > :
    : > > :
    : > > :
    : > > :
    : > > : --
    : > > : HyperART
    : > > : Paul Van Ostaijenlaan 4
    : > > : 3001 Heverlee
    : > > :
    : > > :
    : > > :
    : > >
    : > >
    : >
    : >
    :
    :
     
    Ken Schaefer, Sep 5, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 73blazer
    Replies:
    2
    Views:
    790
    Roger Leigh
    Jan 5, 2004
  2. blur959
    Replies:
    10
    Views:
    353
    Alister Ware
    Aug 13, 2010
  3. Peña, Botp
    Replies:
    1
    Views:
    242
    Robert Klemme
    Jan 24, 2004
  4. Kaya Aykut
    Replies:
    3
    Views:
    105
    BruceL
    Jul 30, 2010
  5. Replies:
    9
    Views:
    150
    smallpond
    Jan 4, 2010
Loading...

Share This Page