#1   Report Post  
Posted to microsoft.public.excel.programming
Naz Naz is offline
external usenet poster
 
Posts: 85
Default Folder size

Hi

I've been given the task of monitoring our folder share size and the effects
of our clear out exercise.
Is there any way in excel to create some code that will give the size of a
particular directory.
So for example if i had a directory c:\temp to find out the size of the
folder, and possible any other data e.g. number of files, files by type?
I know there are probably tools on the net to do this but unfortunately we
can't install any software on or machines, and doing it manually is sooo time
consuming.


All help is appreciated.
--

_______________________
Naz,
London
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Folder size

Try this site
http://www.exceltip.com/st/List_file...Excel/446.html

"Naz" wrote:

Hi

I've been given the task of monitoring our folder share size and the effects
of our clear out exercise.
Is there any way in excel to create some code that will give the size of a
particular directory.
So for example if i had a directory c:\temp to find out the size of the
folder, and possible any other data e.g. number of files, files by type?
I know there are probably tools on the net to do this but unfortunately we
can't install any software on or machines, and doing it manually is sooo time
consuming.


All help is appreciated.
--

_______________________
Naz,
London

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Folder size

A quick and dirty solution is shown below. Before running the code, go
to the Tools menu in VBA, choose References, and scroll down to
"Microsoft Scripting Runtime" and put a check next to that item. Then,
in the code change the line marked with <<<<< to the appropriate
folder name. This code lists the subfolders of StartFolderName with
their subfolder count, size in KB, and file count. It is not
recursive. That is, subfolders of subfolders of subfolders etc are not
listed separately.

I have a free add-in at http://www.cpearson.com/excel/FolderTree.aspx
that will give you a directory listing in almost any format and
including many details about folders, files, subfolders, subfolders of
subfolders, etc.


Sub Start()
Dim FSO As Scripting.FileSystemObject
Dim StartFolderName As String
Dim StartFolder As Scripting.Folder
Dim SubFolder As Scripting.Folder
Dim R As Range
Set R = Range("A1")
R.Value = "Folder Name"
R(1, 2).Value = "Folder Size"
R(1, 3).Value = "SubFolder Count"
Set R = Range("A2")
StartFolderName = "C:\CPearsonWeb" '<<<<<<<<<<<<<<<<<<<<<< CHANGE
Set FSO = New Scripting.FileSystemObject
Set StartFolder = FSO.GetFolder(StartFolderName)
R.Value = StartFolder.Path
R(1, 2).Value = Format(StartFolder.Size / 1024, "#,##0") & " KB"
R(1, 3).Value = Format(StartFolder.SubFolders.Count, "#,##0")
For Each SubFolder In StartFolder.SubFolders
Set R = R(2, 1)
R.Value = SubFolder.Path
R(1, 2).Value = Format(SubFolder.Size / 1024, "#,##0") & " KB"
R(1, 3).Value = Format(SubFolder.SubFolders.Count, "#,##0")
Next SubFolder
Range("A:C").EntireColumn.AutoFit
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Thu, 20 Nov 2008 06:31:02 -0800, Naz
wrote:

Hi

I've been given the task of monitoring our folder share size and the effects
of our clear out exercise.
Is there any way in excel to create some code that will give the size of a
particular directory.
So for example if i had a directory c:\temp to find out the size of the
folder, and possible any other data e.g. number of files, files by type?
I know there are probably tools on the net to do this but unfortunately we
can't install any software on or machines, and doing it manually is sooo time
consuming.


All help is appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting folder size information into cell??? Will Excel Programming 1 May 9th 08 05:27 PM
Folder Tree and size Paul Excel Programming 5 March 15th 07 03:46 AM
Find Folder Size vqthomf Excel Programming 10 September 11th 06 01:26 PM
Folder Size/File Count DMc2004 Excel Programming 2 August 2nd 06 07:59 AM
Folder Size Andibevan[_2_] Excel Programming 3 June 1st 05 03:42 PM


All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"