ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Folder Size (https://www.excelbanter.com/excel-programming/330618-folder-size.html)

Andibevan[_2_]

Folder Size
 
Hi All,

I am trying to build a function that will output the total size (including
sub-folders) of a directory?

Is there a way of easily returning this information or would a loop be
required?

Ta

Andi



Tom Ogilvy

Folder Size
 
Function ShowFolderSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(filespec)
s = UCase(f.Name) & " uses " & f.size & " bytes."
ShowFolderSize = s
End Function


usage:

? Showfoldersize("C:\Data6")
DATA6 uses 28409904 bytes.


--
Regards,
Tom Ogilvy




"Andibevan" wrote in message
...
Hi All,

I am trying to build a function that will output the total size (including
sub-folders) of a directory?

Is there a way of easily returning this information or would a loop be
required?

Ta

Andi





Peter Jausovec

Folder Size
 
Hi,

You will need a loop ... This VBA code should be useful for your problem
(with a little modification :)):
http://www.exceltip.com/st/List_file...Excel/446.html

--
http://blog.jausovec.net


"Andibevan" je napisal:

Hi All,

I am trying to build a function that will output the total size (including
sub-folders) of a directory?

Is there a way of easily returning this information or would a loop be
required?

Ta

Andi




Andibevan[_2_]

Folder Size
 
Thanks Tom


"Tom Ogilvy" wrote in message
...
Function ShowFolderSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(filespec)
s = UCase(f.Name) & " uses " & f.size & " bytes."
ShowFolderSize = s
End Function


usage:

? Showfoldersize("C:\Data6")
DATA6 uses 28409904 bytes.


--
Regards,
Tom Ogilvy




"Andibevan" wrote in message
...
Hi All,

I am trying to build a function that will output the total size (including
sub-folders) of a directory?

Is there a way of easily returning this information or would a loop be
required?

Ta

Andi







All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com