Belini Posted July 26, 2012 Share Posted July 26, 2012 (edited) This script is especially useful to delete those annoying files that comes in USB stick, use with care not to accidentally delete important files of some important unit expandcollapse popup#include <File.au3> #include <Array.au3> #include <String.au3> ; ====================================================== ; AutoIt3 V 3.3.9.4 ; Author: Belini ; Date: 07.26.2012 ; Goal: Delete all the folders and files from one drive. ; Note: Use carefully at your own risk. ; ====================================================== delete_all() Func delete_all() Local $list, $counter = 0 $path = FileSelectFolder("Enter the path of unity", "") If StringLen($path) > 3 Then $path = StringMid($path, 1, 3) $list = _FileListToArray($path) $contar = UBound($list) $contar = $contar - 1 If $contar > 0 Then _ArrayDisplay($list, "Please note these items will be deleted!") $option = MsgBox(1, "delete files", "All files are deleted, or even delete?") If $option = 2 Then MsgBox(4096, "Canceled", "The operation was canceled", 3) Exit EndIf If $option = 1 Then While 1 $counter += 1 If FileExists($path & $list[$counter]) And FileGetAttrib($path & $list[$counter]) = "D" Then DirRemove($path & $list[$counter], 1) If FileExists($path & $list[$counter]) And FileGetAttrib($path & $list[$counter]) = "A" Then FileDelete($path & $list[$counter]) If $counter >= $contar Then ExitLoop Sleep(1) WEnd EndIf MsgBox(4096, "Files deleted successfully!", "All files on drive " & $path & " was deleted.") Else MsgBox(4096, "No files to delete", "There is no file to be deleted in this unit!") EndIf EndFunc ;==>delete_all Edited July 26, 2012 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 26, 2012 Moderators Share Posted July 26, 2012 Out of curiosity, why this line? if StringLen($caminho) > 3 then $caminho = StringMid($caminho, 1, 3) If, for example, I am trying to delete files in C:Temp, the line above moves the directory up to C:. That could make it a bad day "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...
Belini Posted July 26, 2012 Author Share Posted July 26, 2012 If you choose a folder on drive eg E: test, using stringmid + stringlen the result is the same E: why the purpose of this script is to clean the entire unit. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 26, 2012 Share Posted July 26, 2012 Why wouldn't you just quick format? Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Belini Posted July 26, 2012 Author Share Posted July 26, 2012 How to format the drive with Autoit? My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted July 26, 2012 Share Posted July 26, 2012 (edited) Runwait(@ComSpec & " /c "& "format "&$sDrive&" /FS:FAT32 /v:"&$sLabel&" /x /y",@WindowsDir,@SW_SHOW) If you don't care about bad bit detection you can add /Q and it will be faster. Edited July 26, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Belini Posted July 26, 2012 Author Share Posted July 26, 2012 I did not know the command, thanks for pointing. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
JScript Posted July 26, 2012 Share Posted July 26, 2012 (edited) @BelniThis is the MS-DOS commands, be aware that this code snippet: Runwait (@ ComSpec & "/ c" & ... - serves so you can run programs including MS-DOS commands!Type in a DOS window: Format /? You will see an explanation of the command!Regards,João Carlos. Edited July 26, 2012 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! 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