=sinister= Posted December 14, 2005 Share Posted December 14, 2005 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 More sharing options...
seandisanti Posted December 14, 2005 Share Posted December 14, 2005 (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 December 14, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
=sinister= Posted December 14, 2005 Author Share Posted December 14, 2005 All right, cool. But where do I put what I what to search for though? Link to comment Share on other sites More sharing options...
seandisanti Posted December 14, 2005 Share Posted December 14, 2005 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 More sharing options...
Valuater Posted December 14, 2005 Share Posted December 14, 2005 Vulture???? maybe this $temp = FileOpenDialog("find a file to delete", @HomeDrive, "All (*.*)" ) FileDelete($temp) 8) Link to comment Share on other sites More sharing options...
=sinister= Posted December 14, 2005 Author Share Posted December 14, 2005 (edited) heh, sry bout that 'Valuater', I'll try out your script. **edit** Ok, nice 'Valuater' but how do we delete them automatically? Edited December 14, 2005 by =sinister= Link to comment Share on other sites More sharing options...
seandisanti Posted December 14, 2005 Share Posted December 14, 2005 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? Link to comment Share on other sites More sharing options...
=sinister= Posted December 15, 2005 Author Share Posted December 15, 2005 exactly. We want automatic things! Lol. Link to comment Share on other sites More sharing options...
seandisanti Posted December 15, 2005 Share Posted December 15, 2005 exactly. We want automatic things! Lol.that's why i provided a script that will do exactly what you want with minimal modification... Link to comment Share on other sites More sharing options...
=sinister= Posted December 15, 2005 Author Share Posted December 15, 2005 I don't understand your script. you think you can modify it for me plz? Link to comment Share on other sites More sharing options...
seandisanti Posted December 15, 2005 Share Posted December 15, 2005 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 More sharing options...
Moderators SmOke_N Posted December 15, 2005 Moderators Share Posted December 15, 2005 That truly is above and beyond cameronsdad ! 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. Link to comment Share on other sites More sharing options...
=sinister= Posted December 15, 2005 Author Share Posted December 15, 2005 alright thanks. Is it modified? and does Valuater's script in his xpclean menu work? Link to comment Share on other sites More sharing options...
Valuater Posted December 15, 2005 Share Posted December 15, 2005 alright thanks. Is it modified? and does Valuater's script in his xpclean menu work?try it and see...???8) Link to comment Share on other sites More sharing options...
seandisanti Posted December 15, 2005 Share Posted December 15, 2005 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.... 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 More sharing options...
=sinister= Posted December 15, 2005 Author Share Posted December 15, 2005 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 More sharing options...
seandisanti Posted December 15, 2005 Share Posted December 15, 2005 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") EndIfwhose script??? what are you talking about? Link to comment Share on other sites More sharing options...
Valuater Posted December 15, 2005 Share Posted December 15, 2005 yes... thats a very small part of *XPClean Menu*... did you have a question? 8) Link to comment Share on other sites More sharing options...
=sinister= Posted December 15, 2005 Author Share Posted December 15, 2005 What part of your 'Autoclean' section does it search for files and then delete them? Link to comment Share on other sites More sharing options...
Valuater Posted December 15, 2005 Share Posted December 15, 2005 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) 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