Does anybody know how to get a list of folders and their size. My boss is concerned about how much space is being used by user’s home folders. He wants to know the top ten users of network disk space. Is there a way to get this list without going through ALL of the home directories one at a time?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Folder Size (Win2K Server)
Home » Forums » AskWoody support » Windows » Windows Vista, XP and earlier » Questions: Vista, XP back to 3.1 » Folder Size (Win2K Server)
- This topic has 25 replies, 5 voices, and was last updated 21 years ago.
Viewing 2 reply threadsAuthorReplies-
joep517
AskWoody MVPMay 11, 2004 at 6:28 pm #825997Hi Randall,
Check out Karen Kenworthy’s Directory Printer. It has lots of options and versatility.
Joe
--Joe
-
WSrrdavis
AskWoody LoungerMay 11, 2004 at 7:36 pm #826035Joe–
Thanks for your response. I’ve downloaded the Directory Printer. While it appears to have some powerful features, there is way too much information for what I’m looking for. We have hundreds of home folders and it is giving me information on every subfolder of each home folder. If I start with the parent folder for the home directories and check “Search Sub-Folders”, I get information on every sub-folder for every home directory. If I start with a specific user’s home folder, I could just a easily check the properties for each individual home folder–but that would take more time than I have. I wish it had a setting for “Search sub-folders only one level down”.
Is there any other ways to get at the total folder size for all home directories?
-
joep517
AskWoody MVP -
WSbigaldoc
AskWoody LoungerMay 12, 2004 at 10:31 am #826251I don’t know, Joe. Karen seems to be like most software publishers – I guess she responds to volume. I’ve written her a few times with a suggestion or two for her Replicator program, which a lot of us here in The Lounge recommend to others. I’ve never even heard from her and my suggestions haven’t been incorporated. On at least one of those occasions, my suggestion to her was in response to a fellow Lounger who had a problem with Replicator. Oh well…..
-
joep517
AskWoody MVP -
WSbigaldoc
AskWoody Lounger -
WSbigaldoc
AskWoody Lounger -
joep517
AskWoody MVP
-
-
-
joep517
AskWoody MVP -
WSMarkD
AskWoody LoungerMay 12, 2004 at 12:50 am #826138If you want to use VB/VBA for this, you can try using sample code in attached text file (exported VBA code module). Several Windows API functions are used to recursively search subfolders & determine total file size for each “top level” subfolder (ie, one level down from root folder specified). To test this, run the GetTopLevelSubfolderSize sub, specifying root folder. Example, for local hard drive:
GetTopLevelSubfolderSize(“C:”)
The routine will call the GetSubFolderSize sub only for the first-level subfolders found; i.e., will not recurse downward. The GetSubFolderSize sub in turn calls GetFolderSize which recursively searches each subfolder’s contents in order to determine total file size (there is apparently no Windows function that simply returns the total size of a given folder – that would be too easy). The results of all this are printed out to a text file named “C:FolderSize.txt”. Sample output:
Top Level Folder: C:
Top Level Subfolder: C:Dell
Folder Count: 3
File Count: 25
Total File Size: 2,408,157Top Level Subfolder: C:Documents and Settings
Folder Count: 625
File Count: 12574
Total File Size: 1,167,657,261….etc….
Note that File Size is in bytes. Of course code can be modified as necessary to meet your requirements. When testing this, first time ran code (specifying C: as root folder) took a little while to finish, subsequent tests ran much faster (a few seconds to search entire hard drive & write results to text file.) You can expect slower response on a large network (I’m not at work so can’t test this now, though I’ve used similar code at work on network servers & directories). When comparing results to folder’s “Properties” dialog in Windows Explorer, the file & folder count were identical, while the total file size sometimes was identical, but for some folders (such as C:Windows) didn’t match exactly (the difference was insignificant, however). You may want to modify the text file output format so text can be imported into another program like Excel or Access for sorting, etc (use Write #1 statement instead of Print #1, with “fields” for folder name, total size, etc).
HTH
-
WSMarkD
AskWoody LoungerMay 12, 2004 at 1:55 pm #826299In further reply, modified code previously posted to run in Access, so results can be imported into an Access table for further analysis, etc. See attached demo database file (Access 2000 format). Modified GetTopLevelSubfolderSize sub imports text file into table named FolderSize, using a predefined import specification. Run from Immediate window like this:
GetTopLevelSubfolderSize “G:00ZH09B”
Also works using UNC notation:
GetTopLevelSubfolderSize “SERVERNAMENETWORKSHAREH00F00ZH09B”
Tested at work with a shared network folder with 122 top-level subfolders, took a little while to run (first time in particular) but provided accurate results – the file & folder count & total file size (in bytes) were identical to the info provided in Windows Explorer folder Properties dialog for specified folder. The table data can be exported to Excel & sorted by TotalFileSize field (descending) to facilitate identification of network resource hogs.
HTH
-
WSMarkD
AskWoody LoungerMay 12, 2004 at 1:55 pm #826300In further reply, modified code previously posted to run in Access, so results can be imported into an Access table for further analysis, etc. See attached demo database file (Access 2000 format). Modified GetTopLevelSubfolderSize sub imports text file into table named FolderSize, using a predefined import specification. Run from Immediate window like this:
GetTopLevelSubfolderSize “G:00ZH09B”
Also works using UNC notation:
GetTopLevelSubfolderSize “SERVERNAMENETWORKSHAREH00F00ZH09B”
Tested at work with a shared network folder with 122 top-level subfolders, took a little while to run (first time in particular) but provided accurate results – the file & folder count & total file size (in bytes) were identical to the info provided in Windows Explorer folder Properties dialog for specified folder. The table data can be exported to Excel & sorted by TotalFileSize field (descending) to facilitate identification of network resource hogs.
HTH
-
WSrrdavis
AskWoody LoungerMay 12, 2004 at 2:02 pm #826305Hey Mark–
Thanks for the reply. I think this is exactly the kind of tool I’m looking for. However, I’m just a little over my head, here. I probably understand about 80% of the code you included. But that’s how you learn, right? Jump in a little over your and try to figure it out.
I started out by taking the code and dumping in into the Excel VBA editor. I think I’m missing one or more references. Can you pass along which references should be checked.
Also, when I try to compile the code, the first error states “Cannot define a public user-defined type within an object module” at the Type WIN32_FIND_DATA line. This doesn’t sound like a missing reference error. I’ve never created my own types before, so I’m not sure how to correct this error.
If I call the GetTopLevelSubfolderSize procedure within the immediate window, I get an error stating that the procedure or function is not defined. Now that I think about it, this is probably because the code hasn’t compiled, yet.
As I said, this is exactly what I was looking for, but I may need a little hand-holding while I make it work for me. I’m still very much a newbie when it comes to working with the Windows API. Thanks again, Mark, for your contribution.
-
WSMarkD
AskWoody LoungerMay 12, 2004 at 2:35 pm #826312Did you see my 2nd reply (posted not too long ago) – with a demo Access database file attached. I tested code using same demo in Access 2000 & worked OK – not sure if will run “as is” in an Excel code module. The demo may be more useful since it outputs the data to a second text file in a format where the data can be imported into Access, Excel, or any other application that can read a comma-delimited text file. The Type WIN32_FIND_DATA line is a type definition whose purpose is to “translate” the Windows WIN32_FIND_DATA data structure into a format that VB can understand, using the appropriate data types, etc. If trying to run code in Excel, the code should be located in a standard code module, not a Workbook or Worksheet module. Same applies for GetTopLevelSubfolderSize “not defined” error, may be because sub located in an “object” (workbook or worksheet) module rather than stand-alone code module – the sub is declared as public so can be run from the Immediate window. Recommend try testing using the demo Access file, might be simpler…. Also note another reason for using the Windows API functions for this is that, besides efficiency, etc, is that Windows functions called this way do not require external references – the “reference” is the Windows itself, and DLL’s like KERNEL32.DLL, etc. In other words, if you are using any modern (32-bit) version of Windows, they should work (some API functions work only in WIN NT or 2K platforms, but that is not applicable here.)
HTH
-
WSrrdavis
AskWoody Lounger -
WSMarkD
AskWoody LoungerMay 13, 2004 at 11:41 pm #826990Glad you got it sorted out. BTW I checked out the app Legare Coleman mentioned (ShowSize) – seems like a pretty neat (and useful) tool, though I still like being able to do this stuff in code so the data can be captured in a table, spreadsheet, etc. Testing on network, the API code & ShowSize app returned identical results for network folders, so appears code is reliable – I imagine the ShowSize app calls the same API’s to do what it does.
-
WSMarkD
AskWoody LoungerMay 13, 2004 at 11:57 pm #826996PS – one thing I forgot to include in demo (which was done kind of quick-and-dirty at work) was some VBA functions use to “convert” total bytes to KB, MB, or GB for display purposes. Example:
Public Function BytesToKB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToKB = Round(cBytes / (2 ^ 10), intDecimal)
End FunctionPublic Function BytesToMB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToMB = Round(cBytes / (2 ^ 20), intDecimal)
End FunctionPublic Function BytesToGB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToGB = Round(cBytes / (2 ^ 30), intDecimal)
End FunctionExample of use:
Print BytesToKB(1633138056, 0)
1594861
Print BytesToMB(1633138056, 2)
1557.48
Print BytesToGB(1633138056, 2)
1.52The results are consistent with the file size you see displayed in Windows Explorer. These functions may be useful if you want to display file or folder size in a more readable format.
HTH
-
WSMarkD
AskWoody LoungerMay 13, 2004 at 11:57 pm #826997PS – one thing I forgot to include in demo (which was done kind of quick-and-dirty at work) was some VBA functions use to “convert” total bytes to KB, MB, or GB for display purposes. Example:
Public Function BytesToKB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToKB = Round(cBytes / (2 ^ 10), intDecimal)
End FunctionPublic Function BytesToMB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToMB = Round(cBytes / (2 ^ 20), intDecimal)
End FunctionPublic Function BytesToGB(ByRef cBytes As Currency, intDecimal As Integer) As Double
BytesToGB = Round(cBytes / (2 ^ 30), intDecimal)
End FunctionExample of use:
Print BytesToKB(1633138056, 0)
1594861
Print BytesToMB(1633138056, 2)
1557.48
Print BytesToGB(1633138056, 2)
1.52The results are consistent with the file size you see displayed in Windows Explorer. These functions may be useful if you want to display file or folder size in a more readable format.
HTH
-
WSMarkD
AskWoody LoungerMay 13, 2004 at 11:41 pm #826991Glad you got it sorted out. BTW I checked out the app Legare Coleman mentioned (ShowSize) – seems like a pretty neat (and useful) tool, though I still like being able to do this stuff in code so the data can be captured in a table, spreadsheet, etc. Testing on network, the API code & ShowSize app returned identical results for network folders, so appears code is reliable – I imagine the ShowSize app calls the same API’s to do what it does.
-
WSrrdavis
AskWoody Lounger
-
-
WSrrdavis
AskWoody LoungerMay 12, 2004 at 2:02 pm #826306Hey Mark–
Thanks for the reply. I think this is exactly the kind of tool I’m looking for. However, I’m just a little over my head, here. I probably understand about 80% of the code you included. But that’s how you learn, right? Jump in a little over your and try to figure it out.
I started out by taking the code and dumping in into the Excel VBA editor. I think I’m missing one or more references. Can you pass along which references should be checked.
Also, when I try to compile the code, the first error states “Cannot define a public user-defined type within an object module” at the Type WIN32_FIND_DATA line. This doesn’t sound like a missing reference error. I’ve never created my own types before, so I’m not sure how to correct this error.
If I call the GetTopLevelSubfolderSize procedure within the immediate window, I get an error stating that the procedure or function is not defined. Now that I think about it, this is probably because the code hasn’t compiled, yet.
As I said, this is exactly what I was looking for, but I may need a little hand-holding while I make it work for me. I’m still very much a newbie when it comes to working with the Windows API. Thanks again, Mark, for your contribution.
-
-
WSMarkD
AskWoody LoungerMay 12, 2004 at 12:50 am #826139If you want to use VB/VBA for this, you can try using sample code in attached text file (exported VBA code module). Several Windows API functions are used to recursively search subfolders & determine total file size for each “top level” subfolder (ie, one level down from root folder specified). To test this, run the GetTopLevelSubfolderSize sub, specifying root folder. Example, for local hard drive:
GetTopLevelSubfolderSize(“C:”)
The routine will call the GetSubFolderSize sub only for the first-level subfolders found; i.e., will not recurse downward. The GetSubFolderSize sub in turn calls GetFolderSize which recursively searches each subfolder’s contents in order to determine total file size (there is apparently no Windows function that simply returns the total size of a given folder – that would be too easy). The results of all this are printed out to a text file named “C:FolderSize.txt”. Sample output:
Top Level Folder: C:
Top Level Subfolder: C:Dell
Folder Count: 3
File Count: 25
Total File Size: 2,408,157Top Level Subfolder: C:Documents and Settings
Folder Count: 625
File Count: 12574
Total File Size: 1,167,657,261….etc….
Note that File Size is in bytes. Of course code can be modified as necessary to meet your requirements. When testing this, first time ran code (specifying C: as root folder) took a little while to finish, subsequent tests ran much faster (a few seconds to search entire hard drive & write results to text file.) You can expect slower response on a large network (I’m not at work so can’t test this now, though I’ve used similar code at work on network servers & directories). When comparing results to folder’s “Properties” dialog in Windows Explorer, the file & folder count were identical, while the total file size sometimes was identical, but for some folders (such as C:Windows) didn’t match exactly (the difference was insignificant, however). You may want to modify the text file output format so text can be imported into another program like Excel or Access for sorting, etc (use Write #1 statement instead of Print #1, with “fields” for folder name, total size, etc).
HTH
-
-
WSrrdavis
AskWoody LoungerMay 11, 2004 at 7:36 pm #826036Joe–
Thanks for your response. I’ve downloaded the Directory Printer. While it appears to have some powerful features, there is way too much information for what I’m looking for. We have hundreds of home folders and it is giving me information on every subfolder of each home folder. If I start with the parent folder for the home directories and check “Search Sub-Folders”, I get information on every sub-folder for every home directory. If I start with a specific user’s home folder, I could just a easily check the properties for each individual home folder–but that would take more time than I have. I wish it had a setting for “Search sub-folders only one level down”.
Is there any other ways to get at the total folder size for all home directories?
-
-
joep517
AskWoody MVPMay 11, 2004 at 6:28 pm #825998Hi Randall,
Check out Karen Kenworthy’s Directory Printer. It has lots of options and versatility.
Joe
--Joe
-
H. Legare Coleman
AskWoody Plus
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Login screen icon
by
CWBillow
12 minutes ago -
AI coming to everything
by
Susan Bradley
1 hour, 49 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
4 hours ago -
No Screen TurnOff???
by
CWBillow
4 hours, 21 minutes ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
4 hours, 54 minutes ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
16 hours, 31 minutes ago -
How well does your browser block trackers?
by
n0ads
2 hours, 48 minutes ago -
You can’t handle me
by
Susan Bradley
7 hours, 13 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
2 hours, 17 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
1 day, 3 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
7 hours, 23 minutes ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
1 day, 4 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
1 day, 4 hours ago -
Lumma malware takedown
by
EyesOnWindows
16 hours, 38 minutes ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
1 day, 13 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
1 day, 13 hours ago -
Meet Gemini in Chrome
by
Alex5723
1 day, 17 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
1 day, 17 hours ago -
Trump signs Take It Down Act
by
Alex5723
2 days, 1 hour ago -
Do you have a maintenance window?
by
Susan Bradley
5 hours, 57 minutes ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
1 day, 3 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
2 days, 4 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
12 hours, 59 minutes ago -
hibernate activation
by
e_belmont
2 days, 13 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
2 days, 17 hours ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
2 days, 20 hours ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
2 days, 20 hours ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
1 day, 16 hours ago -
Out of band for Windows 10
by
Susan Bradley
3 days, 1 hour ago -
Giving UniGetUi a test run.
by
RetiredGeek
3 days, 8 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.