SoulBlade Posted September 24, 2007 Posted September 24, 2007 Hi! Using code available in this forum, i'm trying to use _FileSearch function in all fixed drives. Here's the code i'm come up to: CODEFunc _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) For $i = 1 to $dc[0] Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $dc, @SW_HIDE, 2+4) next ProcessSetPriority($i_Pid, 5) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ProcessClose($i_Pid) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc ;==>_FileSearch I'm going nuts!
Nahuel Posted September 24, 2007 Posted September 24, 2007 What exactly is the problem? All I see is a typo: Func _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) For $i = 1 to $dc[0] Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $dc, @SW_HIDE, 2+4) next ProcessSetPriority($i_Pid, 5) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ProcessClose($i_Pid) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc ;==>_FileSearch Should be $dc[$i]
SoulBlade Posted September 24, 2007 Author Posted September 24, 2007 What exactly is the problem? All I see is a typo: Should be $dc[$i] You're right! That little typo cost me 30m! I changed that line to: Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $dc[$i] &"\", @SW_HIDE, 2+4) but the function only returns files from the last fixed disk. Any ideias? Thanks for your help!
Nahuel Posted September 24, 2007 Posted September 24, 2007 Could you post an example? I'm trying but I can't get it to work...
wolf9228 Posted September 25, 2007 Posted September 25, 2007 (edited) Hi! Using code available in this forum, i'm trying to use _FileSearch function in all fixed drives. Here's the code i'm come up to: CODEFunc _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) For $i = 1 to $dc[0] Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $dc, @SW_HIDE, 2+4) next ProcessSetPriority($i_Pid, 5) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ProcessClose($i_Pid) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc ;==>_FileSearch I'm going nuts! #include <Array.au3> _ArrayDisplay(_FileSearch('', 1), "_ArrayDisplay() Test") Func _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) $s_Buf = '' For $i = 1 to $dc[0] Step 1 $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & $dc[$I] & "\", "", @SW_HIDE, 2+4) While 1 $s_BufX = StdoutRead($i_Pid) If @error Then ExitLoop $s_Buf &= $s_BufX WEnd next $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc;==>_FileSearch Edited September 25, 2007 by wolf9228 صرح السماء كان هنا
SoulBlade Posted September 25, 2007 Author Posted September 25, 2007 (edited) Thanks Nahuel and Wolf9228! Using Wolf9228 code, i'm trying to delete all *.AAA files found by the _Filesearch function: CODEAutoItSetOption("TrayIconHide", 1) #include <GUIConstants.au3> #include <Array.au3> GUICreate("DiskCleaner 1.0", 250, 80) GUISetIcon("diskcleaner.ico", 0) $run= GUICtrlCreateButton("RUN", 90, 30, 80, 30) GUISetState() Do $msg = GUIGetMsg() select case $msg= $Run GUICtrlSetState ($run, $GUI_DISABLE) $fil1 = _FileSearch('*.aaa') For $ir = 1 to $fil1[0] FileSetAttrib ( $fil1[$ir], "-R") FileDelete($fil1[$ir]) next Case $msg= $GUI_EVENT_CLOSE exit EndSelect Until $msg = $GUI_EVENT_CLOSE Func _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) $s_Buf = '' For $i = 1 to $dc[0] Step 1 $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & $dc[$I] & "\", "", @SW_HIDE, 2+4) While 1 $s_BufX = StdoutRead($i_Pid) If @error Then ExitLoop $s_Buf &= $s_BufX WEnd next $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc;==>_FileSearch Unfortanely i can't make it work. Any ideias? Many thanks! Edited September 25, 2007 by SoulBlade
aslani Posted September 25, 2007 Posted September 25, 2007 I think this; $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & $dc[$i] & "\", "", @SW_HIDE, 2+4)oÝ÷ Ù+©¦¶Þjëh×6$i_Pid = Run(@ComSpec & $s_Command & $dc[$i] & "\" & $s_Mask, "", @SW_HIDE, 2+4) [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version
SoulBlade Posted September 25, 2007 Author Posted September 25, 2007 I think this; $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & $dc[$i] & "\", "", @SW_HIDE, 2+4)oÝ÷ Ù+©¦¶Þjëh×6$i_Pid = Run(@ComSpec & $s_Command & $dc[$i] & "\" & $s_Mask, "", @SW_HIDE, 2+4) Yes it worked! Many thanks Aslani!
wolf9228 Posted September 25, 2007 Posted September 25, 2007 (edited) Thanks Nahuel and Wolf9228! Using Wolf9228 code, i'm trying to delete all *.AAA files found by the _Filesearch function: CODEAutoItSetOption("TrayIconHide", 1) #include <GUIConstants.au3> #include <Array.au3> GUICreate("DiskCleaner 1.0", 250, 80) GUISetIcon("diskcleaner.ico", 0) $run= GUICtrlCreateButton("RUN", 90, 30, 80, 30) GUISetState() Do $msg = GUIGetMsg() select case $msg= $Run GUICtrlSetState ($run, $GUI_DISABLE) $fil1 = _FileSearch('*.aaa') For $ir = 1 to $fil1[0] FileSetAttrib ( $fil1[$ir], "-R") FileDelete($fil1[$ir]) next Case $msg= $GUI_EVENT_CLOSE exit EndSelect Until $msg = $GUI_EVENT_CLOSE Func _FileSearch($s_Mask = '', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $dc = DriveGetDrive( "fixed" ) $s_Buf = '' For $i = 1 to $dc[0] Step 1 $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & $dc[$I] & "\", "", @SW_HIDE, 2+4) While 1 $s_BufX = StdoutRead($i_Pid) If @error Then ExitLoop $s_Buf &= $s_BufX WEnd next $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc;==>_FileSearch Unfortanely i can't make it work. Any ideias? Many thanks! expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> _ArrayDisplay(_FileSearch(1,"",'*au3' ,1) , "Search au3 Type in fixed drives") _ArrayDisplay(_FileSearch(1,"",'*.' ,1) , "Search only dir in fixed drives") _ArrayDisplay(_FileSearch(0,@MyDocumentsDir,'*.' ,1) , "Search only dir in MyDocumentsDir") _ArrayDisplay(_FileSearch(0,@MyDocumentsDir,'*au3' ,1) , "Search au3 Type in MyDocumentsDir") ;For $ir = 1 to $fil1[0] Step 1 ;$fil2 = FileGetShortName($fil1[$ir]) ;Run("attrib.exe " & $fil2 & " -R" , "",@SW_HIDE) ;if StringInStr($fil1[$ir], ".") then ;FileDelete($fil1[$ir]) ;else ;DirRemove($fil1[$ir], 1) ;endif ;next Func _FileSearch($fixedDrives =1, $PATCHDIR = @MyDocumentsDir, $Type ='*' ,$i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' $s_Buf = '' if $fixedDrives = 1 then $dc = DriveGetDrive( "fixed" ) For $i = 1 to $dc[0] Step 1 $i_Pid = Run(@ComSpec & $s_Command & $dc[$I] & "\" & $Type, "", @SW_HIDE, 2+4) While 1 $s_BufX = StdoutRead($i_Pid) If @error Then ExitLoop $s_Buf &= $s_BufX WEnd next else if StringRight($PATCHDIR, 1) <> "\" then $PATCHDIR = $PATCHDIR & "\" $i_Pid = Run(@ComSpec & $s_Command & $PATCHDIR & $Type, "", @SW_HIDE, 2+4) While 1 $s_BufX = StdoutRead($i_Pid) If @error Then ExitLoop $s_Buf &= $s_BufX WEnd endif $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc;==>_FileSearch Edited September 25, 2007 by wolf9228 صرح السماء كان هنا
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