Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching filenames with FileSystemObject

Status
Not open for further replies.

jonathanfrascella

Programmer
Sep 25, 2002
11
GB
I need to be able to search through x number of folders and sub-folders, searching for a particular string within a filename (not interested in the content of the file at all) and I wondered if anyone's got any examples they can point my way?

The project uses descriptive filenames with product codes in them, so for example "frozen peas FP324.xls". It's probably worth noting that the titles will most likely have spaces in them to separate words, so I'll need to replace spaces with "%20" when coding the link to the files, but I'm ok with that.

Any suggestions?
 
Did you look at the "dir" function or at FileSystemobjet.getfile method ? Water is not bad as soon as it stays out human body ;-)
 
That'll be a "no" and "thanks" ;)

GetFileName seems to be what I'm after, but I'm not sure on how to perform the pattern matching as it seems the method needs to be supplied with a complete path and filename (the path can be up to 5 levels deep).

Any more info on this "dir" function??
 
dir function is a VB function but I don't know if it works in VBscripts. btw, you can use it like this :
first call, you specify the patern search :
Code:
dim foundFile
foundFile=dir("c:\temp\*.txt")
then for getting all the files that match, call it without arguments :
Code:
while foundFile <> &quot;&quot;
  ' ... do your stuff ...
  foundFile=dir()
wend
Water is not bad as soon as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top