copyleft Posted January 4, 2005 Share Posted January 4, 2005 I'm a newbie and have searched for the answer for this question but can't seem to find it. Any help you could give me would be great. Thanks. How to search all drives for a specific file when you don't know where it is. Also would like to show progress animation to let user know the PC is searching for the file. Link to comment Share on other sites More sharing options...
ezzetabi Posted January 4, 2005 Share Posted January 4, 2005 (edited) Here we are, about the animation. DIY. You have to modify the udf, or changing the main program you'll just know what drive you are looking at. expandcollapse popup$sFileName = 'Office2003.rar';Set the filename here... $aList = DriveGetDrive ( "FIXED" ) If Not @error Then For $c = 1 to $aList[0] $aRet = _FileSearch($aList[$c] & '\' & $sFileName,7) If $aRet[0] > 0 Then MsgBox(0,'',$aRet[1]) ExitLoop EndIf Next EndIf Func _FileSearch($sIstr, $iSF) ; $iSF can sum up. ; $iSF = 4 means don't return also folders, only files. ; $iSF = 2 means stop at the first found. ; $iSF = 1 means looking in subfolders. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sIstr, $iSF, $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) While $sCS <> - 1 $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If Not (BitAND($iSF, 4) And StringInStr(FileGetAttrib($sCP & $sCF), 'd')) Then $sOutPut = $sOutPut & $sCP & $sCF & @LF If BitAND($iSF, 2) Then ExitLoop EndIf Wend ;And after, if needed, in the rest of the folders. If (BitAND($iSF, 2) Or BitAND($iSF, 3) And $sOutPut = '') Or (BitAND($iSF, 1) And Not BitAND($iSF, 2)) Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) While $iH <> - 1 $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future search $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. While $iH2 <> - 1 $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop If Not (BitAND($iSF, 4) And StringInStr(FileGetAttrib($sFP & $sCF2), 'd')) Then $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. If BitAND($iSF, 2) Then FileClose($iH2) FileClose($iH) ExitLoop 3 EndIf EndIf Wend EndIf Wend $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Edited January 4, 2005 by ezzetabi Link to comment Share on other sites More sharing options...
copyleft Posted January 5, 2005 Author Share Posted January 5, 2005 Thanks. But autoit reports and error in line 22, incorrect function call... $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) Link to comment Share on other sites More sharing options...
ezzetabi Posted January 5, 2005 Share Posted January 5, 2005 Is intended you use the lastest version.Download it and try again.http://www.autoitscript.com/autoit3/files/unstable/autoit/ Link to comment Share on other sites More sharing options...
copyleft Posted January 5, 2005 Author Share Posted January 5, 2005 Many thanks. One last thing. Can I change a line in your script to output the path to clipboard? Link to comment Share on other sites More sharing options...
bshoenhair Posted January 5, 2005 Share Posted January 5, 2005 @ezzetabiNice jobMany thanks.One last thing. Can I change a line in your script to output the path to clipboard?<{POST_SNAPBACK}>I would suugest against using the clipboard because there is a chance it might be overwritten. Link to comment Share on other sites More sharing options...
ezzetabi Posted January 5, 2005 Share Posted January 5, 2005 Sure, just change [...] MsgBox(0,'',$aRet[1]) [...] To [...] ClipPut($aRet[1]) [...] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now