Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Code to retrieve all mdb/mde files on a drive

    I need some quick code on how to search a drive (and subfolders) and return all mdb/mde files (the foldername and filename). Does anyone have some sample code I can look at to do this? I'm under a time crunch and a mind block. I want to write the Foldername and the filename to fields in a table.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Paul,

    Use the Dir() function in a loop, writing to the table when it bingos in on a mde/mdb.

    Sam

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Gotcha - Thanks Sam! I had a mind lapse.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Does this have to be launched from inside Access? There are some other facilities available if you can go the .NET route...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    Paul,

    You can also go to the DOS screen, and while in the folder you want to start with, key this:
    Code:
    dir *.mdb /s >DirText.txt
    When you are done, there will be a text file by the name of "DirText.txt" in the starting folder that will have a listing of all the .mdb files.

    Either run this twice, using >> the second time for appending to the first file, and changing the *.mdb to *.mde. Of course you could also just use *.md? the first time and throw out any none mdb/mde that were found.

    Ya, I know, but sometimes a DOS solution, if this is a one time thing, is so much quicker.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I have something that does this built already - I'll look into posting it into the code bank at some point!

    Just had aplay with Vics code and I reckon these work!
    Code:
    dir *.mdb; *.mde /s >DirText.txt
    --AND--
    dir *.md* /s >DirText.txt
    George
    Home | Blog

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks all. This helped.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by georgev
    I have something that does this built already - I'll look into posting it into the code bank at some point!

    Just had aplay with Vics code and I reckon these work!
    Code:
    dir *.mdb; *.mde /s >DirText.txt
    --AND--
    dir *.md* /s >DirText.txt

    You may car to extend that to
    Code:
    dir <drive>\*.mdb; \*.mde /s >DirText.txt
    --AND--
    dir <drive>\*.md* /s >DirText.txt
    [/QUOTE]

    ..so that you start in the route (or any specified) directory.... just a thought
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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