Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count Files in Directory (XP)

    I believe I read a post regarding counting the number of files in a directory here in the Lounge. I tried searching but have not been successful.

    The code contained something like: strFileName = Dir("" & sPath & "*.*" ")

    I thought there was a reference to "count" somewhere in the code as well. If you could point me in the right direction, that would be great.

    Thanks,
    John

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Count Files in Directory (XP)

    The short version would be something like:
    <code>lngFileCount = CreateObject("Scripting.FileSystemObject").GetFold er(strPath).Files.Count</code>
    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Count Files in Directory (XP)

    Hans,

    Thank you for your suggestion, it worked.

    Regards,
    John

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Count Files in Directory (XP)

    I believe Rory made the suggestion.
    Legare Coleman

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Count Files in Directory (XP)

    <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15> Yep!

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Count Files in Directory (XP)

    Force of habit for most people, I suspect! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Count Files in Directory (XP)

    Sorry Rory.

    I got <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    Regards,
    John

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Count Files in Directory (XP)

    John,
    Not a problem! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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