+ Reply to Thread
Results 1 to 7 of 7

Scan Through All Files and Subdirectories

  1. #1
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Scan Through All Files and Subdirectories

    Hi everyone.

    I am trying to scan through all files within a directory and all subdirectories to find files where the name begins with certain characters. Below is code that will accomplish this for a certain directory, but I do not know how to look through the subdirectories within the specified directory. So, the issues are:

    1. How do I loop through each subdirectory within a specified directory?

    2. I am trying to return the file name, path name (separate from the file name), and modified date. I can return the name. I can return the path, but it includes the name. Is there a way to return just the path?

    3. What is the code to return the modified date of the file?

    Thanks in advance for any help.

    Jason

    Please Login or Register  to view this content.
    Last edited by jasoncw; 01-06-2009 at 11:57 AM.

  2. #2
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    658

    Hope this helps.

    I had a very similiar problem. It was solved by Rylo.
    Here's a link to the thread.
    HTML Code: 
    http://www.excelforum.com/excel-programming/665961-a-way-to-querry-x-xls-files-in-x-subfolders.html
    Within it you will find a files
    with the code he setup for me. I think you could probably
    use it for your situation. It finds specific files and provide directory paths
    w/hyperlinks.

    good luck,

    BDB

  3. #3
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Great link. Thanks a lot, BDB. That answers most of my questions. I still have one remaining question, though. Hopefully someone out there can help me.

    Is it possible to return the modified date of each of the files?

    TIA

    Jason

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Does anyone know if this is possible? Thanks.

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,423
    There are FSO methods to get it. If you use early binding, it makes finding those easy. If you don't know fso, get the help file script56.chm.

    For whatever method, you can use VBA's FileDateTime(filename).

    For some other fso and dos methods see my post at VBAExpress.

    Here is an example FileSearch method. It won't work in 2007.
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Thanks so much for the info, Kenneth. I am very unfamiliar with FSO, so thank you for the help file. I need to do some reading now.

    The property for which I was looking was DateLastModified.

    Jason

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,423
    If the fso help file does not display everything, close and right click it and Unblock it. From the help file:
    Please Login or Register  to view this content.
    The API method from the API Guide:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1