luis713 Posted October 3, 2012 Share Posted October 3, 2012 (edited) Hi, i'm new on autoit forums, i'm trying to delete multiple files by extension, so the question is ¿How can i delete multiple files by extension using an input and " ; " to write different extension? thanks in advance Edited October 8, 2012 by luis713 Link to comment Share on other sites More sharing options...
guinness Posted October 3, 2012 Share Posted October 3, 2012 What did you find when you searched for this (as you're not the first person to ask this question)? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
luis713 Posted October 3, 2012 Author Share Posted October 3, 2012 i was looking for in the forum but i didn't find anything, it shouldn't be difficult but i don't know how Link to comment Share on other sites More sharing options...
guinness Posted October 3, 2012 Share Posted October 3, 2012 i was looking for in the forum but i didn't find anything, it shouldn't be difficult but i don't know howHmm...here is a clue _FileListToArray. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
luis713 Posted October 4, 2012 Author Share Posted October 4, 2012 thanks for replying but i was looking on it and I didn't find how do it, could you help me please? I want to delete all the files found with an specific extension and if it is possible write 2 or more extensions on the same input using ";" to separate extension, here is my little code#include GUICreate("", 200, 120) $input = GUICtrlCreateInput("Extensions to delete", 10, 60, 180, 20) $DeleteFiles = GUICtrlCreateButton("Delete Files", 30, 90, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_event_Close Exit Case $msg = $DeleteFiles FileDelete($extensions) EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 4, 2012 Moderators Share Posted October 4, 2012 Hi, luis713. I assume you're looking to do this in a specific directory? If so, you should be able to do something simple like this: $path = @DesktopDir & "Test" FileDelete($path & "*.exe") "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...
luis713 Posted October 4, 2012 Author Share Posted October 4, 2012 Thanks for replying JLogan, I know how to use that command, do you know if there is a way to you use it with multiple extensions writing only one line? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 4, 2012 Moderators Share Posted October 4, 2012 luis713,You cannot do that in one line. You could put the extensions you are looking for into an array and then loop through the array deleting each separate extension in turn. Or my RecFileListToArray UDF will get you an array of files with multiple extensions within a folder - you can then loop through the array and delete them one by one. Either way is valid - you just need to choose the one you want to use. 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 Link to comment Share on other sites More sharing options...
luis713 Posted October 4, 2012 Author Share Posted October 4, 2012 luis713,You cannot do that in one line. You could put the extensions you are looking for into an array and then loop through the array deleting each separate extension in turn. Or my RecFileListToArray UDF will get you an array of files with multiple extensions within a folder - you can then loop through the array and delete them one by one. Either way is valid - you just need to choose the one you want to use. M23thanks Melba23, could you write a little example? where can I find your UDF? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 5, 2012 Moderators Share Posted October 5, 2012 luis713,could you write a little example?Nice try, but there are examples of how to use the UDF in the first post of the UDF thread - you can find it using the link in my sig below (which also answers your second question). You might also find the Arrays tutorial in the Wiki useful reading if you are unused to working with them. Now you go and see what you can code for yourself using the information you have been given - you know where we are if you run into difficulties. You will get lots of help if you try to do something yourself first - even if it does not work - but we want you to learn a bit as you go along and just giving you the answer will not help you do that. So see you soon with a script I hope. 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 Link to comment Share on other sites More sharing options...
luis713 Posted October 5, 2012 Author Share Posted October 5, 2012 luis713, Nice try, but there are examples of how to use the UDF in the first post of the UDF thread - you can find it using the link in my sig below (which also answers your second question). You might also find the Arrays tutorial in the Wiki useful reading if you are unused to working with them. Now you go and see what you can code for yourself using the information you have been given - you know where we are if you run into difficulties. You will get lots of help if you try to do something yourself first - even if it does not work - but we want you to learn a bit as you go along and just giving you the answer will not help you do that. So see you soon with a script I hope. M23 Thanks for you UDF, sorry but i'm new programming, i think i should save the results returned by _RecFileListToArray and then use filedelete, but it doesn't work, could you help me please? I'm new and I can't do it, I want to learn and I try to understand all the sintax that I read but with this I can't. thanks in advance. here is the code but it doesn't work #include #include "RecFileListToArray.au3" Global $sAutoItDir = StringReplace(StringReplace(@AutoItExe, "AutoIt3.exe", ""), "beta", "") ConsoleWrite($sAutoItDir & @CRLF) ; And here are the .exe files we left out last time $aArray = _RecFileListToArray($sAutoItDir, "*.exe;*.mp3", 1, 1, 0, 2) _ArrayDisplay($aArray, "My gui") FileDelete($aArray) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 5, 2012 Moderators Share Posted October 5, 2012 Hi, luis713. In order to delete the files you need to loop through the array. Try something like this: For $element in $aArray FileDelete($element) Next "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...
luis713 Posted October 5, 2012 Author Share Posted October 5, 2012 I can't, could somebody write an example and a little explanation? Link to comment Share on other sites More sharing options...
BrewManNH Posted October 5, 2012 Share Posted October 5, 2012 I can't, could somebody write an example and a little explanation?Pretty sure that's what JLogan just did. 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 5, 2012 Moderators Share Posted October 5, 2012 (edited) I can't, could somebody write an example and a little explanation? er.. replace FileDelete($aArray) with For $element in $aArray FileDelete($element) Next Edited October 5, 2012 by JLogan3o13 "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...
Moderators Melba23 Posted October 5, 2012 Moderators Share Posted October 5, 2012 luis713, Please stop asking us to write the code for you. We have explained several times how you can do what you want - yet all you have produced is a small piece of code ripped from an example script you found in my UDF. It is obvious that you have no understanding at all of what that code is doing and how to adapt it to do what you want - which is just as well as had it worked you would have deleted a good part of your AutoIt installation! I suggest you go and read the excellent tutorials that you will find here and here so that you begin to understand what you are doing when you code. I suggest you also read that tutorial on Arrays to which I linked earlier - as you show no sign of having done so yet. At your current level of understanding you are very likely to do something drastic to your setup - like deleting your Windows folder - whiel playing about and then you will be in deep trouble. Once you have a basic idea of how AutoIt works and what you are doing then come back and we will start again. 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 Link to comment Share on other sites More sharing options...
luis713 Posted October 5, 2012 Author Share Posted October 5, 2012 thanks to everybody, I could write a code and worked for me, here is the code if somebody can improve it. Here is the codeexpandcollapse popup#include GUICreate("", 200, 120) Global $input = GUICtrlCreateInput("Extensions to delete", 10, 60, 180, 20) $DeleteFiles = GUICtrlCreateButton("Delete Files", 30, 90, 100, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_event_Close Exit Case $msg = $DeleteFiles Local $i $data = GUICtrlRead($Input) ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, ";") If IsArray($arr) Then For $i = 1 to $arr[0] Filedelete("C:test" & $arr[$i]) Next EndIf EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 5, 2012 Moderators Share Posted October 5, 2012 luis713, Well done! 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 5, 2012 Moderators Share Posted October 5, 2012 (edited) Good job Edited October 5, 2012 by JLogan3o13 "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...
luis713 Posted October 6, 2012 Author Share Posted October 6, 2012 thanks, can an administrator mark this topic as solved? 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