Solved

How to grab all the files in a folder

Posted on 2002-05-23
2
154 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:b3cf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 7030331
dim strFile as string
strFile = dir("c:\temp")
while not strFile = empty
  if strFile like "*_tr.gif" then
 
    ... do what with your file ? ...
  end if
  strFile = dir()
wend

CHeers
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7030396
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

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question