Folder properties

lance01

New Member
Joined
Dec 12, 2013
Messages
15
Hi all,

I'm looking for a simple code that can obtain the properties of a windows folder.

On windows if you right click a folder and go to properties you can obtain the number of files/number of folders etc. in a few seconds. However, if you use the recursive method of looking through each folder and subfolder it can take minutes!

I know its possible to get file attributes so is it not possible to get folder attribute of some sort??

Thanks for your help.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi Domenic,
I've looked at FSO and so far have found the following...It tells me the size of the folder but I cannot find an attribute that gives you the number of files and folders in all subfolders of the specified folder like you would find by right clicking a folder and going to properties.
Any ideas????


Sub test2()

ShowFolderSize ("C:\Users\Dell\Desktop\Folder1")

End Sub





Function ShowFolderSize(filespec)

Dim fs, f, s

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.GetFolder(filespec)

s = UCase(f.Name) & " uses " & f.Size & " bytes."

MsgBox s, 0, "Folder Size Info"



a = f.Attributes

B = f.DateCreated

C = f.DateLastAccessed

D = f.DateLastModified

E = f.Drive



End Function
 
Upvote 0
To count files...

Code:
f.Files.Count

To count subfolders...

Code:
f.SubFolders.Count

But you'll have to use the recursive method to count the number of the files, folders, and subfolders within a specified folder.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top