• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get Number of Files in Each Folder

rumshar

Member
Hi Folks,
I have a macro which lists all the folders in given path.It also gives me infos like folder created date,lastmodified date and folder size. I want to add one more column which should give me # of files in each folder. Googling was of not much help.
Can anyone help me with this?
I am uploading my macro herewith.


With Warm Regards
Rudra
 

Attachments

  • List Folders and Other Informations like Size.xlsm
    21.1 KB · Views: 13
I cannot get the macro to work in Excel 2010 or 2013
I added the Microsoft Scripting Runtime to the project
What version of Excel are you using?
 
Hi, rumshar!

Neither could I nor found a property Count for the Folder object... so I'm wondering what does your macro retrieves in your workbook, could you please upload the workbook after running it?

Besides, which Excel version are you using?

Regards!
 
Hi, rumshar!

Neither could I nor found a property Count for the Folder object... so I'm wondering what does your macro retrieves in your workbook, could you please upload the workbook after running it?

Besides, which Excel version are you using?

Regards![/quote

Hi I use Office 2013 @ office and Office 2010 @ home.I have commented out some codes now(which I had added yday only). It is working in my system(office 2010). I am uploading file with retrieved infos. Thanks for trying to help me out. :)

With Regards
Rudra
 

Attachments

  • List Folders and Other Informations like Size(new).xlsm
    20.8 KB · Views: 7
Hi, rumshar!

Very funny... you've commented the part that I mentioned it didn't even compile (and I assume that's with the same that Hui found problems too). Despite of this, you didn't mention what Excel version.

But now, if we assume this last code as valid... your question is circumscribed to something so easy as to initialize a counter when found a folder and then counting the files when listing them (if there's only one level of subfolders)... or to something so difficult as to recurse on subfolders (if there's a free subfolder level).

I'm not gonna adapt your code to this last situation but guide you towards a file where this is just be done (by me, so again... nop). Give a look at these links:
http://chandoo.org/forum/threads/folders-files-matching.6312/
http://chandoo.org/forum/threads/excel-files-documenting-inspector.4715/

Hope it helps,

Regards!
 
Rumshar
The latest version doesn't work in either Excel 2010 or 2013

Two questions:
1. What version of Excel are you using ?
2. What References are you enabling in VBA to allow this to work on your PC?
 
Hi,
I am not finding my reply either here..(I had done it from home)....may be I got disconnected.but somehow file got uploaded......very funny indeed!!!
I use Office 2013 @ office and office 2010 @ home,and my macro works fine on both of my systems(without those commented codes).
@SirJB7 thanks for the links...(http://bit.ly/O2crUD) is blocked here in my office...so will try from home...
Those commented codes were added by me yesterday only....but it failed...that prompted me to create this thread.
With Regards
Rudra
 
Hi, rumshar!

Now things are becoming clear. The code works without the commented lines, so no problem regarding versions and inexistant properties/methods. One point solved. Now the 2nd point, there's no FS objects property/method that retrieves the no. of files of a folder, so you have to appeal to recursive procedures as stated upwards. Another point out.

Regards!
 
Rumshar
The latest version doesn't work in either Excel 2010 or 2013

Two questions:
1. What version of Excel are you using ?
2. What References are you enabling in VBA to allow this to work on your PC?
@Hui
I have not enabled any reference...
 

Hi rumshar !

if you use the slow FileSystemObject, property Count works with its files and folders collections !
Just see on MSDN …
 
Hi, rumshar!
Change the inner sentence of the For...Next loop to this:
Code:
Filecount = FileObj.Files.Count
Regards!
 
Hi, rumshar!
Glad you solved it. Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.
Regards!
 
Back
Top