[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to grab all the files in a folder

Posted on 2002-05-23
2
Medium Priority
?
157 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 200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 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