Shocker Posted May 3, 2013 Share Posted May 3, 2013 Hi there,how can i delete files from different Dirs, with a MsgBox how much and where Files was deleted? Found already different Examples (_FileLisToArray), but can't sort to a working one For example...File is called file*.zipDirs are drive:\myprog\1\, drive:\myprog\2\, drive:\myprog\3\, drive:\myprog\4\If is ready a MsgBox should show...23 Files deleted...8 from myprog\1\9 from myprog\2\4 from myprog\3\2 from myprog\4\Thx! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 3, 2013 Moderators Share Posted May 3, 2013 Hi, Shocker. I would suggest using Melba's RecFileListToArray from the Examples section of this forum. You could easily do something like this: #include <Array.au3> #include <RecFileListToArray.au3> Local $aArray = _RecFileListToArray("C:\MyProg", "File*.zip", 1, 1, 1) _ArrayDisplay($aArray) You could then loop through the array and delete them: For $i = 1 To $aArray[0] FileDelete($aArray[$i]) Next and finally, display your message box: MsgBox(0, "File Delete", "Deleted " & $i & " files.") Shocker 1 "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...
Shocker Posted May 3, 2013 Author Share Posted May 3, 2013 (edited) Thx for reply! Where can i find include RecFileListToArray.au3? Also looking for FileListToArrayRecursive.au3 today... Edited May 3, 2013 by Shocker Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 3, 2013 Moderators Share Posted May 3, 2013 As I mentioned, RecFileListToArray is in the Examples section - see here As for the FileListToArrayRecursive, try a forum search for that one. Shocker 1 "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...
Shocker Posted May 3, 2013 Author Share Posted May 3, 2013 OK, it work - but it´s a litte bit "slowly" because there are 2000+ Subfolders with 135000+ Files Is it possible to improve that a little bit? Link to comment Share on other sites More sharing options...
AZJIO Posted May 4, 2013 Share Posted May 4, 2013 Shocker My other projects or all Link to comment Share on other sites More sharing options...
Shocker Posted May 4, 2013 Author Share Posted May 4, 2013 @AZJIO Thx 4 reply, but this is to much input for me Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 4, 2013 Moderators Share Posted May 4, 2013 Shocker,Searching that number of folders and files will always take a fair time. Could you post the code you used with RecFileListToArray - I might be able to suggest a way to speed up the process. But no promises. 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...
Shocker Posted May 4, 2013 Author Share Posted May 4, 2013 @M23Thx for Reply! RecFileListToArray works fine, no ask! But made a small mistake, Folders are...[drive:]\myprog\1\myupdate[drive:]\myprog\2\myupdate[drive:]\myprog\3\myupdate[drive:]\myprog\4\myupdateand only there are file*.zip to find. So i think it´s time wasting to search complete \myprogWould also like a MsgBox who show how much Files(all) and from which Dirs will be deleted.MsgBox(64,"Search...", "27 Files found." & @CRLF & @CRLF & "(10) in [drive:]\myprog\1\myupdate" &@CRLF& "(7) in [drive:]\myprog\2\myupdate" &@CRLF& "(5) in [drive:]\myprog\3\myupdate" &@CRLF& "(5) in [drive:]\myprog\4\myupdate") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 4, 2013 Moderators Share Posted May 4, 2013 (edited) Shocker,If those paths are literals, then you can do something like this to search just those folders: #include <Array.au3> #include <RecFileListToArray.au3> Global $aList[1] = [0] $sRoot = "Myprog\" For $i = 1 To 4 $aFolderList = _RecFileListToArray($sRoot & $i , "*.zip", 1, 0, 0, 2) _ArrayDisplay($aFolderList) ; Just to show result $aList[0] += $aFolderList[0] _ArrayConcatenate($aList, $aFolderList, 1) Next _ArrayDisplay($aList) ; Just to show resultAny use? M23Edit: I realised that you needed to return the full path for each file as you wee looking in different folders - the parameters have been amended to do this. Edited May 5, 2013 by Melba23 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...
Shocker Posted May 6, 2013 Author Share Posted May 6, 2013 @M23 Thx for reply and changing Script, but get an error... ==> Subscript used with non-Array variable.: $aList[0] += $aFolderList[0] $aList[0] += $aFolderList^ ERROR Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2013 Moderators Share Posted May 6, 2013 Shocker, No doubt there are no files in that folder - so add some errorchecking to make sure you have an array returned before you access it. Somehting like this should do the trick: If Not @error Then $aList[0] += $aFolderList[0] _ArrayConcatenate($aList, $aFolderList, 1) EndIf 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...
Shocker Posted May 6, 2013 Author Share Posted May 6, 2013 (edited) @M23Thx for Reply! Without Update in _RecFileListToArray($sRoot & $i & "update", "*.zip", 1, 0, 0, 2) it dosn't work.I thought of something like...#include #include $drive = "C:" $all = 'file*.zip' Global $dir[4] $dir[0] = '\myprog\1\Update' $dir[1] = '\myprog\2\Update' $dir[2] = '\myprog\3\Update' $dir[3] = '\myprog\4\Update' For $i = 0 to UBound($dir) -1 $files=_FileListToArray($drive & $dir[$i] & "\", $all) _ArrayDisplay($files) NextBut how can i save $files[0] for every Round and add for a complete result? Edited May 6, 2013 by Shocker Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2013 Moderators Share Posted May 6, 2013 Shocker,it dosn't workNot a very helpful statement. What does not work? At the moment the UDF is only looking in the folder you pass which is what you asked me to do - I did say "If those paths are literals". Now you say that "Without Update" you do not get what you expect - what folders do you want the UDF to search? It will search in subfolders to any level if you set the parameters correctly. So how about some useful comments on where exactly you want the UDF to look for .zip files rather then just telling me it does not work - which many years of experience with this UDF tells me is not likely. 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...
Shocker Posted May 6, 2013 Author Share Posted May 6, 2013 (edited) Not a very helpful statement.Sry, my mistake. #include <Array.au3> #include <RecFileListToArray.au3> Global $aList[1] = [0] $sRoot = "c:\Myprog\" For $i = 1 To 4 $aFolderList = _RecFileListToArray($sRoot & $i , "*.zip", 1, 0, 0, 2) _ArrayDisplay($aFolderList) ; Just to show result If Not @error Then $aList[0] += $aFolderList[0] _ArrayConcatenate($aList, $aFolderList, 1) EndIf Next Nothing happen, Array shows [0] 0 #include <Array.au3> #include <RecFileListToArray.au3> Global $aList[1] = [0] $sRoot = "c:\Myprog\" For $i = 1 To 4 $aFolderList = _RecFileListToArray($sRoot & $i & "\update", "*.zip", 1, 0, 0, 2) _ArrayDisplay($aFolderList) ; Just to show result $aList[0] += $aFolderList[0] _ArrayConcatenate($aList, $aFolderList, 1) Next _ArrayDisplay($aList) ; Just to show result Show *.zip's from all single Folders and a complete finally. Edited May 6, 2013 by Shocker Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 7, 2013 Moderators Share Posted May 7, 2013 Shocker,As I explained, you need to tell the UDF if it is to search in subfolders. At the moment that first script is only looking in the Root1, Root2, Root3 & Root4 folders - not in their subfolders. If you want it to search in the subfolders you need to set the $iRecur parameter like this:; What you have now $aFolderList = _RecFileListToArray($sRoot & $i , "*.zip", 1, 0, 0, 2) ; What you need to have $aFolderList = _RecFileListToArray($sRoot & $i , "*.zip", 1, 1, 0, 2)Now the UDF will seach in all the subfolders within the Root1, Root2, Root3 & Root4 folders - which includes update - and so you should find your files. Of course it will also find any other files matching the mask - so be careful. Anyway give the script a try with the change I suggested and see if that does the trick for you. 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...
Shocker Posted May 7, 2013 Author Share Posted May 7, 2013 @M23 Thx for Reply - now it work, many thanks! Is it possible to show how much files was found in each Folder (1-4) in a MsgBox? For altogether i have... MsgBox(64,"Search...", $aList[0] & " Files found.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 7, 2013 Moderators Share Posted May 7, 2013 Shocker, If you want to know how many files were in each folder, why not use the UDF on each folder in turn as you did in the first place? Then it is easy to get the number of files in each folder. If you use the recursive mode of the UDF to look in every folder then it returns only one array and you will have to parse that array to find out how many files were found in each folder. So you choose - either look in all folders and parse the result: #include <Array.au3> #include <RecFileListToArray.au3> $sRoot = "c:\Myprog\" ; Look for files in all subfolders $aFullList = _RecFileListToArray($sRoot, "*.zip", 1, 1, 0, 2) _ArrayDisplay($aFullList) ; Just to show result ; Declare an array to hold the number of files found Global $aCount[5] ; Loop through the files found For $i = 1 To $aFullList[0] ; Now loop through the 4 folders For $j = 1 To 4 ; If the path is in the filename If StringInStr($aFullList[$i], $sRoot & $j) Then ; Add it t0 the count $aCount[$j] += 1 EndIf Next Next ; And display the result of the count MsgBox(0, "Files found", _ "Folder Myprog\1: " & $aCount[1] & @CRLF & _ "Folder Myprog\2: " & $aCount[2] & @CRLF & _ "Folder Myprog\3: " & $aCount[3] & @CRLF & _ "Folder Myprog\4: " & $aCount[4]) Or look in each folder separately: #include <Array.au3> #include <RecFileListToArray.au3> $sRoot = "c:\Myprog\" ; Declare an array to hold the number of files found Global $aCount[5] ; Loop through the folders For $i = 1 To 4 ; Look for files in each folder $aFolderList = _RecFileListToArray($sRoot & $i & "\update", "*.zip", 1, 0, 0, 2) _ArrayDisplay($aFolderList) ; Just to show result ; Add count to array $aCount[$i] = $aFolderList[0] Next ; And display the result of the count MsgBox(0, "Files found", _ "Folder Myprog\1: " & $aCount[1] & @CRLF & _ "Folder Myprog\2: " & $aCount[2] & @CRLF & _ "Folder Myprog\3: " & $aCount[3] & @CRLF & _ "Folder Myprog\4: " & $aCount[4]) Sorted now? M23 Shocker 1 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...
Shocker Posted May 7, 2013 Author Share Posted May 7, 2013 @M23Thx for reply - it works like a charm!!! Many thx... Can you tell me last, how i can delete Files from Array (after MsgBox)?$aAll = $aCount[1]+$aCount[2]+$aCount[3]+$aCount[4] Switch MsgBox(0+4, "Found...", $aAll & " Files found" &@CRLF& @CRLF& _ "Folder Myprog\1: " & $aCount[1] & @CRLF & _ "Folder Myprog\2: " & $aCount[2] & @CRLF & _ "Folder Myprog\3: " & $aCount[3] & @CRLF & _ "Folder Myprog\4: " & $aCount[4] &@CRLF& @CRLF& _ "Delete?") Case 6 EndSwitch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 7, 2013 Moderators Share Posted May 7, 2013 Shocker,Of course. Loop through the array of files that you get and use FileDelete or FileRecycle. But if you use the recursive version of the script you will need to check that the files come from the correct folders - remember that the UDF searches ALL the subfolders. 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...
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