Bllee Posted September 12, 2017 Share Posted September 12, 2017 I'm here today to do my part. for months I'm consuming content, but today I come to provide a script that I did. this script looks for files from fragments of their names. being able to look for extensions or archimes with the same name. searching directories and subdirectories. I did this script only to browse the file and delete, because it is my nescessity in the moment . it has the option of only deleting without warning, or advising which file should be deleted or not. has tray options. I made it in a portuguese brazil, and I will not translate. Test and then tell me what you think. GUI deletar.au3 < this is the main file, it contains the main functions and GUI functions expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <TrayConstants.au3> #RequireAdmin Global $Caminho Global $idCheckbox Global $Warning $Path = IniRead(@ScriptDir & "/config.ini", "Cfg", "Caminho","") $word = IniRead(@ScriptDir & "/config.ini", "Cfg", "Palavra","") $iMsgBoxAnswer = IniRead(@ScriptDir & "/config.ini", "Cfg", "Checkbox","") ;~ $CheckDuplo = "Find N Delet" ;~ If WinExists($CheckDuplo) Then ;~ MsgBox(0,"","Already Running",1) ;~ Exit ; It's already running ;~ EndIf #Region ### START Koda GUI section ### Form= $width = 290 $height = 100 $Form1 = GUICreate("Find N Delet", 290, 106, @DesktopWidth/2 - $width/2, @DesktopHeight/2 - $height/2, $GUI_SS_DEFAULT_GUI, BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE)) GUISetIcon(@ScriptDir & '\icone.ico', -1) TraySetIcon (@ScriptDir & '\icone.ico', -1) $Label1 = GUICtrlCreateLabel("Palavra", 8, 16, 40, 17, $SS_CENTER) $Label2 = GUICtrlCreateLabel("Caminho", 8, 40, 45, 17, $SS_CENTER) $Checkbox = GUICtrlCreateCheckbox("Avisar deleção", 184, 16, 97, 17) if $iMsgBoxAnswer == 1 Then GUICtrlSetState(-1, $GUI_CHECKED) EndIf $idCheckbox = GUICtrlRead($CheckBox) $Button1 = GUICtrlCreateButton("Capturar", 16, 72, 259, 25) $Input1 = GUICtrlCreateInput("", 56, 16, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUICtrlSetData(-1,$word) $Input2 = GUICtrlCreateInput("", 56, 40, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_LEFT)) GUICtrlSetData(-1,$Path) $Button2 = GUICtrlCreateButton("Caminho", 184, 40, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### if FileExists(@ScriptDir & "\config.ini") Then FileSetAttrib(@ScriptDir & "\config.ini", "+H") Else IniWrite(@ScriptDir & "/config.ini", "Cfg", "Caminho",'') IniWrite(@ScriptDir & "/config.ini", "Cfg", "Palavra",'') IniWrite(@ScriptDir & "/config.ini", "Cfg", "Checkbox",'') FileSetAttrib(@ScriptDir & "\config.ini", "+H") EndIf TrayCreateItem("Captura Rápida") TrayItemSetOnEvent(-1,"duplound") TrayCreateItem("") TrayCreateItem("Captura") TrayItemSetOnEvent(-1,"rastrei") TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"_exit") TraySetState($TRAY_ICONSTATE_SHOW) Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 3) Opt("TrayIconHide", 0) opt("TrayOnEventMode", 1) While 1 If ProcessExists ("Finder.exe") Then TraySetState(4) Else TraySetState(1) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $CheckBox If GUICtrlRead($CheckBox) = $GUI_CHECKED Then Global $idCheckbox = 1 Global $Path = $idCheckbox Else Global $idCheckbox = 3 Global $Path = $idCheckbox EndIf Case $Button1 RegEscrever() FazerMagiaAcontecer() Case $Button2 Global $Caminho = selectfolder() GUICtrlSetData($Input2, $Caminho) ;~ MsgBox(0,"",$Caminho ) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd #Region ### Funcoes ### Func duplound() if $Caminho == '' Then $Caminho = $Path IniWrite(@ScriptDir & "/config.ini", "Cfg", "Caminho",$Caminho) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Palavra",GUICtrlRead($Input1)) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Checkbox",4) FazerMagiaAcontecer() EndFunc Func rastrei() if $Caminho == '' Then $Caminho = $Path IniWrite(@ScriptDir & "/config.ini", "Cfg", "Caminho",$Caminho) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Palavra",GUICtrlRead($Input1)) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Checkbox",1) FazerMagiaAcontecer() EndFunc Func RegEscrever() if $Caminho == '' Then $Caminho = $Path IniWrite(@ScriptDir & "/config.ini", "Cfg", "Caminho",$Caminho) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Palavra",GUICtrlRead($Input1)) IniWrite(@ScriptDir & "/config.ini", "Cfg", "Checkbox",$idCheckbox) EndFunc Func _exit() Exit EndFunc Func FazerMagiaAcontecer() Run(@ScriptDir & "\finder.exe") EndFunc Func selectfolder() ; Create a constant variable in Local scope of the message to display in FileSelectFolder. Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "Nenhuma pasta foi selecionada.") Else ; Display the selected folder. ;~ MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) EndIf Return $sFileSelectFolder EndFunc ;==>Example #EndRegion ### Funcoes ### finder.au3 < this file contains the search function, I recommend compiling it into .exe to work properly expandcollapse popup$Path = IniRead(@ScriptDir & "/config.ini", "Cfg", "Caminho","") $word = IniRead(@ScriptDir & "/config.ini", "Cfg", "Palavra","") $iMsgBoxAnswer = IniRead(@ScriptDir & "/config.ini", "Cfg", "Checkbox","") While 1 if $Path == '' Then MsgBox(16,"Erro", "Defina um caminho para rastreio") WinActivate("[TITLE:Find N Delet]") EndIf if $word == '' Then MsgBox(16,"Erro", "Defina uma palavra para rastreio") WinActivate("[TITLE:Find N Delet]") EndIf Searchengine($Path,$word, $iMsgBoxAnswer) ;~ MsgBox(0,'',"oi") WEnd Func Searchengine($Path,$word, $iMsgBoxAnswer) $Path = $Path ;<---- The path where all begins... dim $folders[4] $Files = "" $dirs = "" $result = "" $word = $word if $iMsgBoxAnswer == '' then $iMsgBoxAnswer = 2 If StringInStr(FileGetAttrib($path),"d") Then $folders[0] = 1 $folders[1] = $Path While 1 For $c = 1 to $folders[0] If StringRight($folders[$c],1) == "\" Then $Folders[$c] = StringLeft($folders[$c],StringLen($folders[$c])-1) $search = FileFindFirstFile($folders[$c] & "\*.*") If $search <> -1 Then While 1 $result = FileFindNextFile($search) If @error Then ExitLoop If $result <> "." AND $result <> ".." Then $result = $folders[$c] & "\" & $result If StringInStr(FileGetAttrib($result),"d") Then $dirs = $dirs & "|" & $result $files = $files & "|" & $result ; << --- Remove this line if you do not want the folders names in the final list... ;or use an other var if you want divide. Else ;~ proxima linha mudar comando ;~ If StringInStr($result, $word ) Then Msgbox(0,"",$result & " - " &$word &" exists in the string") If StringInStr($result, $word ) And Not StringInStr($result, '$RECYCLE.BIN' ) Then ;~ Msgbox(0,"",$result & " - " &$word &" exists in the string") if $iMsgBoxAnswer == 1 then $iMsgBoxAnswer = Msgbox(33,"Deletar ?","Caminho: " &$result & @CRLF & "Palavra: " &$word) Select Case $iMsgBoxAnswer = 1 ;OK FileRecycle($result) Case $iMsgBoxAnswer = 2 ;Cancel EndSelect if $iMsgBoxAnswer == 3 then FileRecycle($result) if $iMsgBoxAnswer == 4 then FileRecycle($result) EndIf EndIf EndIf WEnd FileClose($search) EndIf Next If $dirs = "" Then ExitLoop $folders = 0 $dirs = StringRight($dirs,StringLen($dirs) - 1) $folders = StringSplit($dirs,"|") $dirs = "" WEnd EndIf ;~ $files = StringRight($files,StringLen($files) - 1) ;~ $files = StringReplace($files,"|",@crlf) ;~ FileWrite("l:\list.txt",$files) Exit EndFunc icone.ico < my .ico ♥ setup finder.exe < with the help of the program innosetup-5.5.9.exe I did an final installer. Enjoy and any doubt comment Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 12, 2017 Moderators Share Posted September 12, 2017 Moved to the correct forum Bllee 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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