Link to home
Start Free TrialLog in
Avatar of b3cf
b3cf

asked on

How to grab all the files in a folder

Hi

     Could someone advice me on how i could grab all the files that matches
a pattern in a folder.

ex  *_tr.gif     in       c:\temp folder

Thanx
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Grab and do what with them?  You can do this:

SearchPattern = "c:\temp\*_tr.gif"
DestinationFile = "c:\myGIFlist.txt"

Shell(Comspec(Environ) & " /c dir " & SearchPattern & " > " & DestinationFile

These are now all listed in a text file at c:\myGIFlist.txt


--or--
similar to angelIII, you could use the pattern directly in the dir statement:

dim strFile as string
strFile = dir$("c:\temp\&_tr.gif")
while not strFile = vbnullstring
 '  ... do what with your file ? ...
 strFile = dir$()
wend