WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Searcher
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Locate a Folder


Question:

What is the cleanest way to look for a folder.

Answer:

I would use the File Searcher Extender. Here is some undebugged code that locates all directories named 'temp'.
;Load File Search Extender
AddExtender("WSRCH34I.DLL")
;Display dialog box.
BoxOpen("Directory searcher","")
;Define name of folder to look for
dirname="temp"
;Define the root directory to start the search from
root = 'c:\'
;Initalize search
;Specify a file name you know doesn't exist (i.e. xxxxxxx.xxx)
;Use flags 16:recurse sub-directories and 32:return directory names
handle=SrchInit(root, "xxxxxxx.xxx", "", 0, 16|32)
BoxTitle("Searching %drvroot% for %Dirname%")
While 1
      ;Find the next file.
      hit = SrchNext(handle)
      ;No more files to search give up
      If hit == ""  Then Break
      ;Display dialog box with folder name
      BoxText( "Dirname: " : hit)
      ;Extract out the last folder name in the folder path
      dirnamefound = ItemExtract( ItemCount( hit, "\" )-1, hit, "\" )
      ;See if found folder name matches your folder name
      If StrUpper(dirnamefound)==StrUpper(dirname)
         Message("Found",hit)
      EndIf
EndWhile
SrchFree(handle)

Article ID:   W16859
File Created: 2007:07:03:14:26:38
Last Updated: 2007:07:03:14:26:38