Sign in to follow this  
Followers 0
=sinister=

find >> delete

20 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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....

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Vulture????

maybe this

$temp = FileOpenDialog("find a file to delete", @HomeDrive, "All (*.*)" )
FileDelete($temp)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

heh, sry bout that 'Valuater', I'll try out your script.

**edit**

Ok, nice 'Valuater' but how do we delete them automatically?

Edited by =sinister=

Share this post


Link to post
Share on other sites

Vulture????

maybe this

$temp = FileOpenDialog("find a file to delete", @HomeDrive, "All (*.*)" )
FileDelete($temp)

8)

i assumed it was a file with an unknown path, i mean if he's going to select the file manually, why script it at all?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

exactly. We want automatic things! Lol.

Share this post


Link to post
Share on other sites

exactly. We want automatic things! Lol.

that's why i provided a script that will do exactly what you want with minimal modification...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

That truly is above and beyond cameronsdad :P!


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

try it and see...???

8)


NEWHeader1.png

Share this post


Link to post
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.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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

Share this post


Link to post
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?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

yes... thats a very small part of *XPClean Menu*...

did you have a question?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0