trids Posted February 20, 2004 Share Posted February 20, 2004 Okay .. I confess I misunderstood the helpfile on DriveSpaceTotal and DriveSpaceFree: I understood that the difference between these figures would yield the size of a folder .. $sPath = "D:\temp\target\" $nSpaceTotal = DriveSpaceTotal($sPath) $nSpaceFree = DriveSpaceFree($sPath) $nSpaceUsed = $nSpaceTotal - $nSpaceFree msgbox (4096 + 32,"",$nSpaceTotal & @LF & $nSpaceFree & @LF & $nSpaceUsed) However, the figures that are returned evidently apply only to the root of the path argument, regardless of the folder specified. I submit, though, that the helpfile conspired in my delusion :Remarks DriveSpaceFree may even work when a complete directory path (that exists) is given.Nevertheless .. if FileGetSize won't help either (the documentation says "Does not work on directories" .. then how does one cleverly find out the size of a folder??? 3.0.94.0 (unstable) NT4 Link to comment Share on other sites More sharing options...
cmallett Posted February 20, 2004 Share Posted February 20, 2004 In AutoHotkey you can do it this way. I'm pretty sure you can do something similar AutoIt3 using its FindFirst/NextFile, but it takes a little bit more code:FileSelectFolder, folder_name, C:\,, Choose a folder to analyze: TotalSize = 0 Loop, %folder_name%\*.*,, 1 TotalSize += %A_LoopFileSizeKB% MsgBox, Total size in KB of "%folder_name%" is %TotalSize%. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 20, 2004 Developers Share Posted February 20, 2004 This script uses the good old dir command and displays the totals for the given selection including the subdirs... Just compile into xyz.exe and type the command: xyz c:\yourdir or xyz c:\yourdir\*.ext (only tested in WinXP) If $CmdLine[0] = 0 then exit runwait('cmd /c Dir "' & $CmdLine[1] & '" /s /x > files.txt',"",@SW_HIDE) $ifile = FileOpen("files.txt", 0) ; Check if file opened for reading OK If $ifile = -1 Then MsgBox(0, "Error", "Unable to open: files.txt") Exit EndIf While 1 $Fi_Rec = FileReadLine($iFile) If @error = -1 Then ExitLoop If StringInStr($Fi_Rec,"Total Files Listed:") Then MsgBox(4096,"Dirsize","Dirsize for selection:" & $CmdLine[1] & @cr & FileReadLine($iFile) & @cr & FileReadLine($iFile)) endif Wend SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
cmallett Posted February 20, 2004 Share Posted February 20, 2004 (edited) Forgot to mention: My example above is recursive already, by means of the last parameter being 1. This means that all folders, regardless of how deeply nested, are included in the total size. Edited February 20, 2004 by cmallett Link to comment Share on other sites More sharing options...
Somerset Posted February 20, 2004 Share Posted February 20, 2004 from command line dir c: /s /a > directory.txt Link to comment Share on other sites More sharing options...
Developers Jos Posted February 20, 2004 Developers Share Posted February 20, 2004 from command line dir c: /s /a > directory.txt i wonder where you got that idea .. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
trids Posted February 21, 2004 Author Share Posted February 21, 2004 dir c: /s /a > directory.txt.. Thanks for the tip - nice workaround 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