Warning Posted February 7, 2011 Posted February 7, 2011 (edited) I want to search and delete EVERY Thumbs.db on my computer. Is that possible? cuz' I've found the FileFindFirstFile & FileFindNextFile, But is that possible to let me make search the whole computer? Edited February 7, 2011 by Warning
flyingboz Posted February 7, 2011 Posted February 7, 2011 I want to search and delete EVERY Thumbs.db on my computer. Is that possible? cuz' I've found the FileFindFirstFile & FileFindNextFile, But is that possible to let me make search the whole computer?the functionality you want is commonly called a (big word warning) recursive function.take a look at any of the dos functions that support a "/s" switch. I've written a few similar utils, you can either process these individually, or use them to create a listing that you can then (another big word) iterate through.The wisdom/usefullness of wasting your time messing around with a bunch of inconsequential files that the os creates by default, and will recreate unless you jump through hoops, we will ignore. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
MvGulik Posted February 7, 2011 Posted February 7, 2011 (edited) whatever Edited February 8, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
Moderators Melba23 Posted February 7, 2011 Moderators Posted February 7, 2011 Warning,Look at the RecFileListToArray UDF in my sig. It will let you list all the files on a drive matching a defined mask into an array. You can then loop through that array to delete the files. You will have to run it on each drive in turn, but that is what DriveGetDrive is for! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Tripredacus Posted February 7, 2011 Posted February 7, 2011 (edited) For things like this, wouldn't you just use the command interpreter? RunWait (@ComSpec & " /c del thumbs.db /s" ) Edited February 7, 2011 by Tripredacus Twitter | MSFN | VGCollect
BrewManNH Posted February 7, 2011 Posted February 7, 2011 For things like this, wouldn't you just use the command interpreter? RunWait (@ComSpec & " /c del thumbs.db /s" ) That's what I was going to suggest myself. I hate reinventing the wheel when I don't have to. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Skitty Posted February 7, 2011 Posted February 7, 2011 (edited) That's what I was going to suggest myself. I hate reinventing the wheel when I don't have to. Some one might get here from google by typing in "Find files in whole computer", so in case some one does, the code will be right here expandcollapse popupDim $FolderName = @ScriptDir Dim $FileCount = 0 ScanFolder($FolderName) MsgBox(0,"Done","Folder Scan Complete. Scanned " & $FileCount & " Files") Func ScanFolder($SourceFolder) Local $Search Local $File Local $FileAttributes Local $FullFilePath $Search = FileFindFirstFile($SourceFolder & "\*.*") While 1 If $Search = -1 Then ExitLoop EndIf $File = FileFindNextFile($Search) If @error Then ExitLoop $FullFilePath = $SourceFolder & "\" & $File $FileAttributes = FileGetAttrib($FullFilePath) If StringInStr($FileAttributes,"D") Then ScanFolder($FullFilePath) Else LogFile($FullFilePath) EndIf WEnd FileClose($Search) EndFunc Func LogFile($FileName) $FileCount += 1 ToolTip($FileName,0,0) EndFunc Edit: I don't know why I replied to the above post.... Edited February 7, 2011 by System238
UEZ Posted February 7, 2011 Posted February 7, 2011 (edited) This is the fastest search code I known to search for files and folders. expandcollapse popup#include <Array.au3> $bench = TimerInit() $Array = FLwStr('c:\', '(?i)\bthumbs\.db\z', True, 1) ConsoleWrite("Benchmark: " & Round(TimerDiff($bench) / 1000, 4) & " ms" & @CRLF) _ArrayDisplay($Array) ; #FUNCTION# ====================================================================================== ; Name ..........: FLwStr() ; Description ...: Findet Dateien und/oder Ordner in einem Verzeichnisbaum ; Syntax ........: FLwStr($sSD, Const[ $sPat = '', Const[ $iF = 3]]) ; Parameters ....: $sSD - Suchort (mehrere Suchorte durch | trennen) ; Const $sPat - [optional] regulärer Ausdruck für zu findende Datei/Ordnernamen (default:'') ; Const $iF - [optional] 1=nur Dateien, 2=nur Ordner, 3=Dateien+Ordner (default:3) ; Const $iSSFlag - [optional] 0=Rückgabearray mit Anzahl Elemente in $Array0, 2=Rückgabearray ohne Anzahl Elemente ; Return values .: Success - Return Array with Matches with $Array[0] = Count ; Failure - Return "" and set @error ; Author ........: AspirinJunkie ; Remarks .......: Funktionsweise ist iterativ - nicht rekursiv ; Example .......: Yes ; #include <Array.au3> ; $aTmp = FLwStr(@WindowsDir & '|' & @ProgramFilesDir, "^Temp$", 2) ; _ArrayDisplay($aTmp) ; ================================================================================================= Func FLwStr($sSD, Const $sPat = '', Const $iF = 3, Const $iSSFlag = 0) ;by AspirinJunkie Local $sRet = "", $sSubD = "" For $i In StringSplit($sSD, '|', 2) If StringRight($i, 1) = '\' Then $i = StringTrimRight($i, 1) If Not FileExists($i) Then Return SetError(2, 0, "") $sSubD &= '|' & $i Next Local $FFFF, $FFNF, $sDir, $iC Local $aD, $hDLL = DllOpen('kernel32.dll') If Not ($iF = 3 Or $iF = 1 Or $iF = 2) Then Return SetError(3, 0, "") Do $iC = StringInStr($sSubD, '|', 2, -1) If @error Or $iC = 0 Then ExitLoop $iC = StringLen($sSubD) - $iC $sDir = StringRight($sSubD, $iC) $sSubD = StringTrimRight($sSubD, $iC + 1) $FFFF = FileFindFirstFile($sDir & '\*') If $FFFF <> -1 Then Do $FFNF = FileFindNextFile($FFFF) If @error Then ExitLoop If @extended Then If BitAND(StringRegExp($FFNF, $sPat) * 2, $iF) Then $sRet &= $sDir & '\' & $FFNF & '\|' $aD = DllCall($hDLL, 'dword', 'GetFileAttributesW', 'wstr', $sDir & '\' & $FFNF) If @error Or BitAND($aD[0], 0x400) Then ContinueLoop $sSubD &= '|' & $sDir & '\' & $FFNF ElseIf BitAND(StringRegExp($FFNF, $sPat), $iF) Then $sRet &= $sDir & '\' & $FFNF & '|' EndIf Until 0 FileClose($FFFF) EndIf Until 0 DllClose($hDLL) If $sRet = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimRight($sRet, 1), '|', $iSSFlag) EndFunc ;==>FLwStr You can use the array to delete your files afterwards. Br, UEZ Edited February 7, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ReaImDown Posted February 8, 2011 Posted February 8, 2011 (edited) For things like this, wouldn't you just use the command interpreter? RunWait (@ComSpec & " /c del thumbs.db /s" ) there a way to make it delete everything with a certain file extension? ie. RunWait (@ComSpec & " /c del *.db /s" ) EDIT: What do you know... that works lol any way to log what was deleted? Edited February 8, 2011 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
JoHanatCent Posted February 8, 2011 Posted February 8, 2011 any way to log what was deleted? RunWait (@ComSpec & " /c del *.db /s /q > Log.txt&&start log.txt" )
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