schilbiz Posted November 14, 2007 Share Posted November 14, 2007 Hey guys I am wondering if there is a function that will read the contents of a specific location and output a list of the folder names and the size. Like if it searched \\server\ and the below folders were in there. It would read out: Users 1.5g Misc 350.45mb Name 3g Etc.. I have been looking in the Helpfiles but have not located the function that would do this. As always thanks for your help. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 Hey guys I am wondering if there is a function that will read the contents of a specific location and output a list of the folder names and the size.Like if it searched \\server\ and the below folders were in there. It would read out:Users 1.5gMisc 350.45mbName 3gEtc.. I have been looking in the Helpfiles but have not located the function that would do this.As always thanks for your help.By far, the coolest (graphical) version of that ever made is OverDisk.To do it in AutoIt would require _FileListToArray() and a recursive search function to tally up the file sizes. There are many recursive searches already posted on the forums. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
schilbiz Posted November 14, 2007 Author Share Posted November 14, 2007 By far, the coolest (graphical) version of that ever made is OverDisk.To do it in AutoIt would require _FileListToArray() and a recursive search function to tally up the file sizes. There are many recursive searches already posted on the forums. Thanks a lot Psalty, my job just got a whole lot easier. OverDisk does work pretty good, and I will search the forums to see what other people have come up with. I will also look at _FileListToArray(), I was looking for a _FolderListToArray and didn't find anything of that sort.Again, Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 Thanks a lot Psalty, my job just got a whole lot easier. OverDisk does work pretty good, and I will search the forums to see what other people have come up with. I will also look at _FileListToArray(), I was looking for a _FolderListToArray and didn't find anything of that sort.Again, ThanksFrom the help file for _FileListToArray():Parameters$sPath Path to generate filelist for. $sFilter Optional the filter to use, default is *. Search the Autoit3 helpfile for the word "WildCards" For details. $iFlag Optional: specifies wheather to return files folders or both$iFlag=0(Default) Return both files and folders$iFlag=1 Return files only$iFlag=2 Return Folders only Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
schilbiz Posted November 14, 2007 Author Share Posted November 14, 2007 I put this together and it gives me a readout of all the Folder names. What would I change in the code to have it read folder size as well? #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray("\\server\data", "*.*", 2) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Folders Located.") Exit EndIf _ArrayDisplay($FileList,"$FileList") Link to comment Share on other sites More sharing options...
weaponx Posted November 14, 2007 Share Posted November 14, 2007 Another good graphical program is WinDirStat: http://windirstat.info/Also since the detail view in an explorer window doesn't display folder sizes I use ExplorerXP:http://www.explorerxp.com/ Link to comment Share on other sites More sharing options...
schilbiz Posted November 14, 2007 Author Share Posted November 14, 2007 (edited) I imagine it would use this function $size = FileGetSize("AutoIt.exe")oÝ÷ ÛZ¶«jgz»0¢é]"ëjwpêÞÂ¥t¬z+bØb±Êy«¢+Ø%¹±Õ±Ðí¥±¹ÔÌÐì(%¹±Õ±ÐíÉÉä¹ÔÌÐì(ÀÌØí¥±1¥ÍÐõ}¥±1¥ÍÑQ½ÉÉä ÅÕ½ÐìÀäÈìÀäÈíÍÉÙÈÀäÈíÑÅÕ½Ðì°ÅÕ½Ð쨸¨ÅÕ½Ðì°È¤)%¡9½Ð%ÍÉÉä ÀÌØí¥±1¥ÍФ¤¹¡ÉɽÈôĤQ¡¸)5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí9¼½±ÉÌ1½Ñ¸ÅÕ½Ðì¤)á¥Ð)¹%)}ÉÉå¥ÍÁ±ä ÀÌØí¥±1¥ÍаÅÕ½ÐìÀÌØí¥±1¥ÍÐÅÕ½Ðì¤ I apologize for the simple questions but I am real new to AutoIt and unfortunetly I am not in a place where I can test and try out things without endangering the integrity of the servers/workplace. I will deffinetly play with it more when I get home. Edited November 14, 2007 by schilbiz Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 (edited) Here's something to play with. This opens an instance of Explorer to the parent folder, selects the subfolder, opens its properties, waits for the property page text to stop updating (for a big folder this can take a while), and the extracts the results from the window text: expandcollapse popupOpt("WinTitleMatchMode", 4) $sDir = "C:\Program Files" $sSubDir = "AutoIt3" ; Open parent window ShellExecute($sDir & "\") WinWait("[CLASS:CabinetWClass; Title:" & $sDir & "]") $hWin = WinGetHandle("[CLASS:CabinetWClass; Title:" & $sDir & "]") WinActivate($hWin) WinWaitActive($hWin) ; Select subdirectory ControlSend($hWin, "", "[CLASSNN:SysListView321]", $sSubDir) ; Open properties of subdirectory ControlSend($hWin, "", "", "!fr") WinWait("[CLASS:#32770; TITLE:" & $sSubDir & " Properties]") $hSubWin = WinGetHandle("[CLASS:#32770; TITLE:" & $sSubDir & " Properties]") WinActivate($hSubWin) WinWaitActive($hSubWin) ; Wait for updates to stop for at least 3sec $sText = WinGetText($hSubWin) While 1 Sleep(3000) ; 3 sec delay If $sText = WinGetText($hSubWin) Then ExitLoop $sText = WinGetText($hSubWin) WEnd ControlClick($hSubWin, "", "[CLASS:Button; TEXT:OK]") ; Click OK $avText = StringSplit($sText, @LF) $sSize = "" For $n = 1 To $avText[0] If StringInStr($avText[$n], "Size:") Then $sSize = $avText[$n + 1] ExitLoop EndIf Next MsgBox(64, "Results", "Size of " & $sDir & "\" & $sSubDir & "\ = " & $sSize) Enjoy... Edited November 14, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DaleHohm Posted November 14, 2007 Share Posted November 14, 2007 I can name that tune in nine lines: $fso = ObjCreate("Scripting.FileSystemObject") $oRootFolder = $fso.GetFolder("C:\") $oFolders = $oRootFolder.SubFolders ConsoleWrite("There are " & $oFolders.count & " folders" & @CR) For $oFolder in $oFolders If $oFolder.name = "System Volume Information" then ContinueLoop; Special folder, skip ConsoleWrite(@TAB & "Size of " & $oFolder.name & " = " & $oFolder.size & " bytes" & @CR) Next Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 (edited) I can name that tune in nine lines: $fso = ObjCreate("Scripting.FileSystemObject") $oRootFolder = $fso.GetFolder("C:\") $oFolders = $oRootFolder.SubFolders ConsoleWrite("There are " & $oFolders.count & " folders" & @CR) For $oFolder in $oFolders If $oFolder.name = "System Volume Information" then ContinueLoop; Special folder, skip ConsoleWrite(@TAB & "Size of " & $oFolder.name & " = " & $oFolder.size & " bytes" & @CR) Next Dale Excellent! Thanks Dale! I poked around in Scriptomatic looking for a WMI interface like that, sure I had seen it before. Didn't think to look at the scripting interface. That loop crashes when it hits Documents and Settings on mine, but it's tweakable. P.S. Tested on another machine just fine, probably a user folder on the other one I don't have perms for. Edited November 15, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
schilbiz Posted November 15, 2007 Author Share Posted November 15, 2007 Nice, thanks to both of you these work great! 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