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?
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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
-
Office gets current release
by
Susan Bradley
1 hour, 2 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
17 hours, 34 minutes ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 hours, 6 minutes ago -
Stop the OneDrive defaults
by
CWBillow
18 hours, 23 minutes ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
1 day, 4 hours ago -
X Suspends Encrypted DMs
by
Alex5723
1 day, 6 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
1 day, 6 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
1 day, 7 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
1 day, 8 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
20 hours, 13 minutes ago -
Enabling Secureboot
by
ITguy
1 day, 3 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
1 day, 15 hours ago -
No more rounded corners??
by
CWBillow
1 day, 11 hours ago -
Android 15 and IPV6
by
Win7and10
1 day, 1 hour ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
2 days, 4 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
2 days, 7 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
2 days, 1 hour ago -
Windows Update orchestration platform to update all software
by
Alex5723
2 days, 14 hours ago -
May preview updates
by
Susan Bradley
2 days, 1 hour ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
1 day, 17 hours ago -
Just got this pop-up page while browsing
by
Alex5723
2 days, 6 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
2 days, 3 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
1 day, 5 hours ago -
At last – installation of 24H2
by
Botswana12
3 days, 5 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
3 hours, 35 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
3 days, 18 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
1 day, 16 hours ago -
Limited account permission error related to Windows Update
by
gtd12345
4 days, 7 hours ago -
Another test post
by
gtd12345
4 days, 7 hours ago -
Connect to someone else computer
by
wadeer
8 hours, 55 minutes 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.