Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: multiple file types
hand=srchInit("c:\","*.txt|*.dll","","",16)I am trying to seach for multiple file types. Pretty easy huh??
There are two possible workarounds
I kind of recommend this one.
fn=srchnext(handle) if fn == "" then break fnext=strlower(FileExtension(fn)) if fnext!="txt" && fnext!="dll" then continue
The script works fine. Only that it locates folders that does not contain .Doc and .xls files.
Have any clues?
The script:
AddExtender("wsrch34I.dll") Dir=DirGet( ) TopSrchDir = 'C:\' nHandle = srchInit(TopSrchDir,"*.doc","",0,48) while 1 Path=srchNext(nHandle) PathTrunk=StrSub(Path,4,-1) if Path=="" then break ;pause("Found",xxx) CommandLine="xcopy %Path%*.* \\ServerNt\Backup\%PathTrunk%*.* /c /q /h /r /m /e /I" fp=FileOpen("temp876.num","WRITE") FileWrite(fp,CommandLine) FileClose(fp) FileAppend("temp876.num","%PathProg%Command.bat") FileAppend("temp876.num","%Path%%LF1%") FileDelete("temp876.num") endwhile srchFree(nHandle) Run("notepad.exe","%Dir%Command.bat")
AddExtender("wsrch34I.dll") Dir=DirGet( ) TopSrchDir = 'C:\' nHandle = srchInit(TopSrchDir,"*.*","",0,16) OldPath="XXXX-:GARGAGE:-XXXX" while 1 TheFilename=srchNext(nHandle) if TheFilename=="" then break ext=StrLower(FileExtension(TheFilename)) if ext != "doc" && ext != "xls" then continue path=FilePath(TheFileName) PathTrunk=StrSub(Path,4,-1) if stricmp(PathTrunk,OldPath) == 0 then continue OldPath=PathTrunk ;pause("Found",xxx) CommandLine="xcopy %Path%*.* \\ServerNt\Backup\%PathTrunk%*.* /c /q /h /r /m /e /I" fp=FileOpen("temp876.num","WRITE") FileWrite(fp,CommandLine) FileClose(fp) FileAppend("temp876.num","%PathProg%Command.bat") FileAppend("temp876.num","%Path%%LF1%") FileDelete("temp876.num") endwhile srchFree(nHandle) Run("notepad.exe","%Dir%Command.bat")
Article ID: W12555
Filename: How to Search for Multiple File Types.txt
File Created: 2001:03:01:15:34:02
Last Updated: 2001:03:01:15:34:02