Solved

How to grab all the files in a folder

Posted on 2002-05-23
2
152 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
2 Comments
 
LVL 142

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 53
How to create a duplicate finder Application 9 120
VBA filters 2 59
How to read File Date Created using VB6 8 38
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now