Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CMD to search through network drive 1

Status
Not open for further replies.

dvirgint

Programmer
Jun 28, 2010
85
CA
I'm writing to see if anyone can tell me the fastest way of extracting filenames from a network drive I have offsite. I have some search criteria provided by users with the help of a userform in Access.

I've tried using FSO which in my experience in this situation is the slowest. I've also tried using CMD with WScript.Shell, which is faster, but I've recorded that it take approximately 7 minutes to perform the check with the macro. Using the Windows search bar in an explorer window provides results in about a minute or less. The parent folders I am searching through have approximately 35,000 folders each containing about 1 to 2 files.

Here is the command I use with CMD with WScript.Shell :
Code:
strTemp = CreateObject("WScript.Shell").Exec("CMD /C DIR """ & "N:\" & _
                  Me.txtRegion.Value & "\" & Me.txtYear.Value & "\" & _
                  Me.txtDossier.Value & "*.*"" /S /B /A:-D").StdOut.ReadAll

The results are then split into an array and processed.

Does anyone have any suggestions for how to improve this code?
 
Looks very promising! Thanks for sharing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top