RBrown1375 Posted February 5, 2015 Share Posted February 5, 2015 Problem: Users are saving music and video files on my servers and it is taking up too much space. The company allows them to save some, but not this much. Solution: I'm trying to write an AutoIT script that can look at all files and folders on a drive and return the folder name and number of file types: .avi, .mp3 and so on. It would be helpful if this script to save the results to a log file so the IT team can send emails to the users or managers asking them to remove the files. If you know if a template or script that is close to my needs please let me know. Thank You Link to comment Share on other sites More sharing options...
jguinch Posted February 5, 2015 Share Posted February 5, 2015 I made a script in this sense. Look at in my signature, for _DirGetSizeByExtension, with _Example2(). RBrown1375 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
jdelaney Posted February 5, 2015 Share Posted February 5, 2015 You can always change dirs to the root of the folder you want to search from, and run command: dir /s *.avi dir /s *.mp3 It's quick...else you would have to look for the _filelisttoarrayrecursive function...I believe it's in the beta, and newer releases, but I'm using an older autoit version, so it's not there yet. RBrown1375 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
RBrown1375 Posted February 6, 2015 Author Share Posted February 6, 2015 Thank You both for your replies. I will check both out. Cheers Link to comment Share on other sites More sharing options...
RBrown1375 Posted February 10, 2015 Author Share Posted February 10, 2015 (edited) right now I feel like such a newbie. I can't get this code to work and I have now botched it so bad I need another set of eyes please. All I'm trying to do is build a small GUI app that will allow a user to enter the path and file type and the app will recurse through the folders and return all the files of that type. I have this close to working but I'm lost on the search functions. Any would be great. I did look over the examples before asking for help. Thanks expandcollapse popup#include <Array.au3> ; Only required to display the arrays #include <File.au3> #include <MsgBoxConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #RequireAdmin Example() Func Example() ; Places the input box in the top left corner displaying the characters as they ; are typed. Local $sValue1 = InputBox("File Search", "What File Extension Are You Looking For?", "", "", _ -1, -1, -1, 0) Local $sValue2 = InputBox("File Search", "Enter The File Path?", "", "", _ -1, -1, -1, 0) ; Display the result. MsgBox($MB_SYSTEMMODAL, "", $sValue2 & $sValue1) Local $sValue1 = StringLeft($sValue1, StringInStr($sValue1, "", Default, -1)) If StringRight($sValue2, 5) = "beta\" Then $sValue2 = StringTrimRight($sValue2, 5) EndIf ConsoleWrite($sValue2 & @CRLF) ; A sorted list of all files and folders in the Userdata1 Location Local $aArray = _FileListToArrayRec($sValue2 ,$FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Sorted tree") ; And now ignoring the "Include" folder ; $aArray = _FileListToArrayRec($sMusicFind, "*||include", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "No 'Include' folder") ; A sorted list of all but the .exe files in the \AutoIt3 folder ; $aArray = _FileListToArrayRec($sMusicFind, "*|*.exe", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "Non .EXE files") ; And here are the .exe files we left out last time ; $aArray = _FileListToArrayRec($sMusicFind, "*.exe", $FLTAR_FILES) ; _ArrayDisplay($aArray, ".EXE Files") ; A test for all folders and .exe files only throughout the folder tree, omitting folders beginning with I (Icons and Include) ; $aArray = _FileListToArrayRec($sMusicFind, "*.exe||i*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "Recur with filter") ; Look for icon files - but exlude the "Icons" folder ; $aArray = _FileListToArrayRec($sMusicFind, "*.ico||ic*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT) If @error Then MsgBox($MB_SYSTEMMODAL, "Ooops!", "No ico files found") Else _ArrayDisplay($aArray, "Icon files not in 'Icons' folder") EndIf ; And to show that the filter applies to files AND folders when not recursive ; $aArray = _FileListToArrayRec($sValue1, "*.mp3", $FLTAR_FILESFOLDERS, $FLTAR_NORECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "Non-recur with filter") ; The filter also applies to folders when recursively searching for folders ; $aArray = _FileListToArrayRec($sMusicFind, "Icons", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "Folder recur with filter") ; Note the exlude_folder parameter is ignored when looking for folders - "Icons" will be excluded but "Include" will still be there ; $aArray = _FileListToArrayRec($sMusicFind, "*|ic*|i*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT) ; _ArrayDisplay($aArray, "'Icons' out - 'Include' in") ; The root of C:\Windows showing hidden/system folders ; $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS) ; _ArrayDisplay($aArray, "Show hidden folders") ; The root of C:\Windows omitting hidden/system folders ; $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS + $FLTAR_NOHIDDEN + $FLTAR_NOSYSTEM) ; _ArrayDisplay($aArray, "Hide hidden folders") EndFunc ;==>Example Edited February 10, 2015 by RBrown1375 Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted February 10, 2015 Moderators Solution Share Posted February 10, 2015 RBrown1375,This should give you the idea: #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sExt = InputBox("File Search", "What File Extension Are You Looking For?") Local $sPath = InputBox("File Search", "Enter The File Path?") ; Display the result. MsgBox($MB_SYSTEMMODAL, "", $sPath & @CRLF & $sExt) ; A sorted list of all files Local $aArray = _FileListToArrayRec($sPath, "*." & $sExt, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT) If @error Then MsgBox($MB_SYSTEMMODAL, "Ooops!", "No files found") Else _ArrayDisplay($aArray, "Sorted tree") EndIf EndFunc ;==>ExamplePlease ask if you have any questions. 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...
RBrown1375 Posted February 10, 2015 Author Share Posted February 10, 2015 Thank You very much!! I see what I did wrong. Have a great day!! 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