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

Searching files based on name

Status
Not open for further replies.

w1nn3r

ISP
Sep 12, 2001
179
0
0
US
Hello,
I would like to write a script that can scan a specific location and it's subfolders for folders and/or files that are all numbers. I'm rather new to this so any help or guidance would be appreciated. Upon finding them I'd like the option to delete them, I'd also like the option of setting a minimum file/folder name length. I know it sounds like a tall order but it will be appreciated.
 
Code:
CONST strFolder = "C:\temp\"

set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")

function searchDir(strDir, strQuery)
	set objFolder = objFSO.GetFolder(strDir)
	for each objSubFolder in objFolder.SubFolders
		strResults = strResults & searchDir(objSubFolder.Path, strQuery)
	next
	
	for each objFile in objFolder.Files
		if (inStr(objFile.Name, strQuery)) then strResults = strResults & objFile.Name & vbNewLine
	next
	searchDir = strResults
end function

msgbox searchDir(strFolder, ".txt")
-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top