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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Files

Status
Not open for further replies.

nevets2001uk

IS-IT--Management
Jun 26, 2002
609
GB
I'm working on a piece of vbscript to take input from the page user from a textbox. From this string I'd like to search a number of folders on a server for files with macthing filenames. The documents are all word files. There's something like 2000 of these files and preferably the search will look through the folders and files and once a match is found it will display a link on the page which can then be clicked to open the document.

I'm sure after time I could bodge some code to do this correctly but I was wondering if anyone might have an idea on how to do this in a more technical way.

Any comments appriciated,
Steven
 
Maybe as you say there is a technology to do this, but I'd "bodge" it, too.

Check out the Regular Expressions object (requires the IE 5.5 or higher installed on the server) which will make handling the string from the text box easier (for example if you want to split it into separate words). And you'll also need the FileSystem Object, which allows you to manipulate the file system (for example to iterate through folders and files).

I don't know if this helps
 
Try this:
set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sDir = <Path to default starting folder>

inputfn = inputbox(&quot;Enter File Name&quot;)

set Fldr = objFSO.GetFolder(sDir)

set subfldr = Fldr.subfolders

for each sFldr in subfldr
set Fldr = objFSO.GetFolder(sfldr)

for each file in Fldr.Files
if file.name = <inputfn> then
<code to create the link>
end if

next

next

set WshShell = nothing
set objFSO = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top