Chimaera Posted May 9, 2011 Share Posted May 9, 2011 Ok im trying to do a checkbox that when it is ticked then gives me an approximate size of the item of the checkbox type So for example ignoring the checkbox bit for the moment say i choose drive c:\ and i have the need to know the total size of the mp3's that are on that drive I looked at FileGetSize but it wont do directory's, so i tried this $drive = "C:\" $size = DirGetSize($drive & "*.mp3") Msgbox(0,"","Size: " & Round($size / 1024 / 1024 / 1024 ) & " GB") But it doesn't like the wildcard, $drive on its own works fine but i need the total of the wildcarded mp3's Any suggestions which way to go? Thanks Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2011 Moderators Share Posted May 9, 2011 (edited) Chimaera,Use my RecFileListToArray UDF to get an array of all the .mp3 files on the drive - then loop through them using FileGetSize. M23Edit: This works fine for me:#include <Array.au3> #include <RecFileListToArray.au3> $sRoot = "M:\Music\MP3\" $aListing = _RecFileListToArray($sRoot, "*.mp3", 1, 1) $nSize = 0 For $i = 1 To $aListing[0] $nSize += FileGetSize($sRoot & $aListing[$i]) / 1048576 Next MsgBox(0, "Total", Round($nSize, 2) & "Mb")And the total is not too far removed from that returned by my file manager. Edited May 9, 2011 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...
Chimaera Posted May 9, 2011 Author Share Posted May 9, 2011 (edited) Does it support just drive selection? when i try this it dosent work #include <Array.au3> #include <File.au3> #include "RecFileListToArray.au3" Local $aArray, $drive $drive = "C:\" $type = ".mp3" $aArray = _RecFileListToArray($drive, $type, 0, 1, 1) _ArrayDisplay($aArray) Or have i done something wrong? and is FileGetSize($array) the correct way to use an array with FileGetSize? as i really dont use arrays with the stuff i do EDIT sorry you posted just before i did Thx for the help Edited May 9, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2011 Moderators Share Posted May 9, 2011 (edited) Chimaera, Or have i done something wrong?Yup! $type = "*.mp3" ; Do not forget the wildcard is FileGetSize($array) the correct wayNo, you need to use a loop as I showed in the example I posted above. If you are not comfortable with arrays, then I recommend the Arrays tutorial in the Wiki. Arrays are a fundamental part of coding and you should at least understand the basics of how they work as many AutoIt functions use them as return values. M23 Edit: Glad you got it sorted. Edited May 9, 2011 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...
Chimaera Posted May 9, 2011 Author Share Posted May 9, 2011 (edited) One small other thought, there are some windows .mp3s i will need to exclude they have known names so i can easily do a list Now i see from the udf that this is required $sExclude_List = "First.mp3";"second.mp3" etc But at what point do i include the excludes if that makes sense lol Just thought is it possible to search for more than one type of music? for eg $aListing = _RecFileListToArray($sRoot, "*.mp3","*.wma", 1, 1)? Edited May 9, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2011 Moderators Share Posted May 9, 2011 (edited) Chimaera, You need to include the excludes () when you call the function - like this: $aListing = _RecFileListToArray($sRoot, "*.mp3", 1, 1, 0, 1, "First.mp3;Second.mp3") Note the syntax - you only need a single pair of quotes around the list of excludes, with semicolons between them. How many excludes will you have? If there are quite a few you might be better removing them from the returned array rather than excluding them from the listing function itself - let me know if you want some help along those lines. M23 Edit: Just thought is it possible to search for more than one type of music? for eg $aListing = _RecFileListToArray($sRoot, "*.mp3","*.wma", 1, 1)?Yes, you can do that but you need to use the correct syntax as I explained above: $aListing = _RecFileListToArray($sRoot, "*.mp3;*.wma", 1, 1) All clear? Edited May 9, 2011 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...
Chimaera Posted May 9, 2011 Author Share Posted May 9, 2011 (edited) How many excludes will you have? If there are quite a few you might be better removing them from the returned array rather than excluding them from the listing function itself - let me know if you want some help along those lines. M23something like this for vista"Kalimba.mp3" "Maid with the Flaxen Hair.mp3" "Sleep Away.mp3" "Amanda.wma" "Despertar.wma" "Din Din Wo (Little Child).wma" "Din Din Wo (Little Child).wma" "Distance.wma" "I Guess You're Right.wma" "I Ka Barra (Your Work).wma" "Love Comes.wma" "Muita Bobeira.wma" "OAM's Blues.wma" "One Step Beyond.wma" "Symphony_No_3.wma"and for xp"Beethoven's Symphony No. 9 (Scherzo).wma" "New Stories (Highway Blues).wma"something of that nature there maybe the odd one or two extraIm not sure if you spotted this edit on my last postJust thought is it possible to search for more than one type of music?for eg$aListing = _RecFileListToArray($sRoot, "*.mp3","*.wma", 1, 1)? is that correctThanks for the help and advice, i think the double answering didnt help lol Edited May 9, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted May 9, 2011 Author Share Posted May 9, 2011 (edited) Here's the final code Gives total for all music off common formats on drive with exceptions of all windows music #include <Array.au3> #include <RecFileListToArray.au3> $sRoot = "C:\" $aListing = _RecFileListToArray($sRoot, "*.3gp;*.aiff;*.aac;*.alac;*.dct;*.flac;*.m4p;*.mpc;*.mp3;*.ogg;*.ra;*.rm;*.wma", 1, 1, "Kalimba.mp3;Maid with the Flaxen Hair.mp3;Sleep Away.mp3;Amanda.wma;Despertar.wma;Din Din Wo (Little Child).wma;Distance.wma;I Guess You're Right.wma;I Ka Barra (Your Work).wma;Love Comes.wma;Muita Bobeira.wma;OAM's Blues.wma;One Step Beyond.wma;Symphony_No_3.wma;Beethoven's Symphony No. 9 (Scherzo).wma;New Stories (Highway Blues).wma") $nSize = 0 For $i = 1 To $aListing[0] $nSize += FileGetSize($sRoot & $aListing[$i]) / 1048576 Next MsgBox(0, "Total", Round($nSize, 2) & " Mb") Many thanks to Melba23 for the help Edited May 9, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2011 Moderators Share Posted May 9, 2011 (edited) Chimaera,You are obviously looking to exclude the files that ship with Windows. As these are all in the same subfolder, you can do this easily by using the $sExclude_List_Folder parameter as explained in the function header and the thread lead post. This works for my Vista setup:; $aListing = _RecFileListToArray($sRoot, "*.mp3;*wma", 0, 1, 0, 1, "", "x86_microsoft-windows-musicsamples_31bf3856ad364e35_6.0.6000.16386_none_a81d9e66b53cd1c0") ;It does make the line a little shorter! M23Edit: New forum software does not like long single lines of code. Edit: Although not by much it seems! Edited May 9, 2011 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...
Chimaera Posted May 9, 2011 Author Share Posted May 9, 2011 (edited) This is a little shorter #include <Array.au3> #include <RecFileListToArray.au3> $sRoot = "c:\" $includes = '"*.3gp;*.aiff;*.aac;*.alac;*.dct;*.flac;*.m4p;*.mpc;*.mp3;*.ogg;*.ra;*.rm;*.wma"' $excludes = '"Kalimba.mp3;Maid with the Flaxen Hair.mp3;Sleep Away.mp3;Amanda.wma;Despertar.wma;Din Din Wo (Little Child).wma;Distance.wma;I Guess You?re Right.wma;I Ka Barra (Your Work).wma;Love Comes.wma;Muita Bobeira.wma;OAM?s Blues.wma;One Step Beyond.wma;Symphony_No_3.wma;Beethoven?s Symphony No. 9 (Scherzo).wma;New Stories (Highway Blues).wma"' $aListing = _RecFileListToArray($sRoot, $includes, 1, 1, $excludes) $nSize = 0 For $i = 1 To $aListing[0] $nSize += FileGetSize($sRoot & $aListing[$i]) / 1048576 Next MsgBox(0, "Total", Round($nSize /1024, 2) & " Gb Of Music") Edited May 9, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() 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