Nirvana6 Posted July 19, 2008 Share Posted July 19, 2008 (edited) This script search for as many keywords as you want (you can also use wildcards )and deletes the files found.Seek_Destroy.exeHere is the codeexpandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\..\Downloads\Costumization\ICONS\Axialis Librarian\Icons\Vista Icons Pack 3.0\Other\Other 50.ico #AutoIt3Wrapper_outfile=Seek&Distroy.exe #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_AU3Check=n #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #comments-start; _FileSearch( "Path and Mask", <$nOption>, <$cpusaver>, <$dirfilter>, <$filefilter>) ;----PARAMETERS----- ;$nOption - <Optional (0 - normal, 1- recursive)> ;$cpusaver - <Optional (0 - normal, 1 - CPU Friendly, but Slower)> ;$dirfilter - <Optional (0 - list directories, 1 - filter out directories)> ;$filefilter- <Optional (0 - list files, 1 - filter out files)> #comments-end #include<array.au3> #include <File.au3> $Keytxt = 0 $Keyno = InputBox("Number Of Keywords","How many keywords you wish to search for ? ") Global $Mask[$Keyno] = [ "shit.txt" ];you can also use wildcards while $Keytxt < $Keyno $keyword= InputBox ("Keyword "& $Keytxt , "Keyword " &$Keytxt) $Keytxt += 1 StringStripWS ( $keyword, 8 ) _ArrayAdd($Mask,$keyword) WEnd $Path="D:\" ChoosePath("1") Func ChoosePath($c) $Path= InputBox ("Disk Drive" , "Type the Drive Letter") EndFunc Start(" ") $PathChoose = MsgBox(4 ,"Path" ,"Choose another Path ?") if $Pathchoose = 6 then ChoosePath("1") else Exit EndIf Func Start($s) For $i = 0 to UBound($Mask)-1 ConsoleWrite($Mask[$i] & @CRLF) $a = _FileSearch( $Path&$Mask[$i], 1, 0, 1, 0) $Confirm = Msgbox (4 , "Confirmation" , "Are you sure you want to delete the file containing : " & @CRLF & $Mask[$i]) If $Confirm=7 then ContinueLoop if $Confirm=6 then For $X = 0 to Ubound($a)-1 FileDelete($a[$X]) Next EndIf Next EndFunc ;file searching functions Func _FileSearch($szMask, $nOption = 0, $cpusaver = 0, $dirfilter = 0, $filefilter = 0) $szRoot = "" $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If Not StringInStr($szMask, "\") Then $szRoot = @ScriptDir & "\" Else While StringInStr($szMask, "\") $szRoot = $szRoot & StringLeft($szMask, StringInStr($szMask, "\")) $szMask = StringTrimLeft($szMask, StringInStr($szMask, "\")) WEnd EndIf If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn, $cpusaver, $dirfilter, $filefilter) Else While 1 $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @error If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer), "D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) WEnd FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn, $cpusaver, $dirfilter, $filefilter) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList, 1) $szRoot = StringLeft($szPathList, StringInStr($szPathList, "*") - 1) & "\" $szPathList = StringTrimLeft($szPathList, StringInStr($szPathList, "*") - 1) WEnd EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn, 1), "*") EndIf EndFunc Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN, $cpusaver, $dirfilter, $filefilter) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @error If $cpusaver = 1 Then Sleep(1) ;OPTIONAL FOR CPU SAKE If $szBuffer <> "." And $szBuffer <> ".." Then If StringInStr(FileGetAttrib($ROOT & $szBuffer), "D") Then If $dirfilter = 0 Then $RETURN = $RETURN & $ROOT & $szBuffer & "*" Else If $filefilter = 0 Then $RETURN = $RETURN & $ROOT & $szBuffer & "*" EndIf EndIf $szBuffer = FileFindNextFile($hFile) WEnd FileClose($hFile) EndIf EndFuncSpecial thanks to :danwilli for the search UDFJamesBrooks for helping me everytime when i neededweaponx for the FOR loop containing For $i = 0 to UBound($Mask)-1 muttleyLater Edit$Keytxt = 0 the 0 should be changed with 1 Edited July 19, 2008 by Nirvana6 Link to comment Share on other sites More sharing options...
James Posted July 19, 2008 Share Posted July 19, 2008 No problem Nirvana muttley Looks nice! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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