Solved

How to grab all the files in a folder

Posted on 2002-05-23
2
149 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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

21 Experts available now in Live!

Get 1:1 Help Now