Jump to content

find >> delete


Recommended Posts

I need a script that will search for a specific file (gif, au3, etc..) and then delete it. I also need it to search under My Documents. I was looking under (i think it was him) Vultures 'XPClean Menu' to find something similar. haven't found anything yet. thanks.

Link to comment
Share on other sites

I need a script that will search for a specific file (gif, au3, etc..) and then delete it. I also need it to search under My Documents. I was looking under (i think it was him) Vultures 'XPClean Menu' to find something similar. haven't found anything yet. thanks.

third time i've posted this today, but here ya go: in it's current form it does a file list of all files on C:\ and subdirectories. all you have to do is add block condition to remove the file if it's the one you were looking for, and change the starting folder if you want.

$tosearch = "C:"
$output = FileOpen("c:\filelist.txt",2)
Global $deep = 0
$start = TimerInit()
RecFileSearch($tosearch)
FileClose($output)
MsgBox(0,"done","it only took " & int(TimerDiff($start)/1000) & " seconds")
Func RecFileSearch($current)
    $deep = $deep +1
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
    Dim $file = FileFindNextFile($search)
    If @error Or StringLen($file)<1 Then ExitLoop
    FileWriteLine($output,$current & "\" & $file & "     " & FileGetSize($file))
    If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then RecFileSearch($current & "\" & $file)
    WEnd
    FileClose($search)
EndFunc

***edit*** fixed typo

Edited by cameronsdad
Link to comment
Share on other sites

All right, cool. But where do I put what I what to search for though?

that's the part you have to add; i'd suggest an input that sets a variable to the filename to search for, and then you have to add a check, maybe instead of creating a list of everything, just have it evaluate every $file and delete it if it's the file in question. or you could leave the list, then read in the list at the end, and delete all of the files listed that contain the file name string you entered....
Link to comment
Share on other sites

I don't understand your script. you think you can modify it for me plz?

If you don't understand it, i think explaining it may be a better way to go.

$tosearch = "C:";this is the starting directory (no ending backslash) currently hardcoded, but you could take input for this...
$output = FileOpen("c:\filelist.txt",2);this is where the list is saved
$start = TimerInit();this creates a filestamp when the real execution starts
RecFileSearch($tosearch);this calls the function, passing the starting directory
FileClose($output);once the function is done, this closes the output list
MsgBox(0,"done","it only took " & int(TimerDiff($start)/1000) & " seconds");and this lets you know how long it took.

Func RecFileSearch($current);the function takes a string containing the folder currently being searched, on the first call
                        ;this would be C: or whatever path you take from input
    Local $search = FileFindFirstFile($current & "\*.*");creates a handle to access all files in the directory being searched
    While 1;infinite loop
    Dim $file = FileFindNextFile($search);this grabs the next file in the folder
    If @error Or StringLen($file)<1 Then ExitLoop;if an empty string is returned, or if the error is set because there are no more files
                                            ;the function exits
    FileWriteLine($output,$current & "\" & $file & "     " & FileGetSize($file));this writes the filename and size to the list
    If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then RecFileSearch($current & "\" & $file)
    ;if the file is marked as a directory, but not the . or .. directory, then the function is called for that directory
    WEnd;once the call from the last line (if the function called itself) returns, this loops for the next file/folder
    FileClose($search);once all of the folders and files have been listed, the $search handle is closed
EndFunc;and the function is done.
Link to comment
Share on other sites

alright thanks. Is it modified? and does Valuater's script in his xpclean menu work?

i've only heard great things about his program, but then he's the only one that ever talks about it....

:P j/k i haven't tried his script myself, but i've seen several people instructed to use it by some of the real guru's on here, so i think it's atleast as good as the advice that he gives...

try it and see...???

as far as my code, the only modification to it, was i removed a counter that i'd put in during debugging and had missed removing when i was done with it; and i commented every line for you to be able to understand and tailor to your needs yourself. So now you have a fishing pole, and the option to use it or starve.

Link to comment
Share on other sites

This is part of what I found in your script

If BitAND(GUICtrlRead($Auto_11), $GUI_CHECKED) = $GUI_CHECKED Then
                        $Del_File = "\*.bak"
                        Call("Delete_Unused")
                    EndIf
Link to comment
Share on other sites

This is part of what I found in your script

If BitAND(GUICtrlRead($Auto_11), $GUI_CHECKED) = $GUI_CHECKED Then
                        $Del_File = "\*.bak"
                        Call("Delete_Unused")
                    EndIf
whose script??? what are you talking about?
Link to comment
Share on other sites

What part of your 'Autoclean' section does it search for files and then delete them?

right below this line

;--------------- Functions --------------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Func Delete_Temp()
;this deletes everything in $dir
    $fHandle = FileFindFirstFile($Temp_Dir & $Temp_File)

.... blah.....blah

there are three types of search and delete below that line

8)

NEWHeader1.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...