+ Reply to Thread
Results 1 to 12 of 12

count the number of files in a specified folder

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    count the number of files in a specified folder

    Is there a way that I could monitor the number of files in a folder and its contents (including subfolders)?

    Folder A: (total count of files)
    Subfolder
    Folder A.1 no. of files containing boy
    Folder A.2 no. of files containing girl
    Folder A.3 no. of files containing boys and girls

    thanks

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: count the number of files in a specified folder

    Thread moved to Programming forum

  3. #3
    Registered User
    Join Date
    05-22-2009
    Location
    UK
    MS-Off Ver
    Excel 2000,2003 and regretably 2007
    Posts
    77

    Re: count the number of files in a specified folder

    i use a excel sheet that lists all files within said folder for another one of my projects i suppose you could generate a list on another sheet and then use a =COUNTA(A:A) forumula if this is what you are looking for get back to me i will be able to assist for you, if you want you can send me your sheet and i can implicate the formula for you

    Teshi

  4. #4
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    Smile Re: count the number of files in a specified folder

    Quote Originally Posted by teshiburu1988 View Post
    i use a excel sheet that lists all files within said folder for another one of my projects i suppose you could generate a list on another sheet and then use a =COUNTA(A:A) forumula if this is what you are looking for get back to me i will be able to assist for you, if you want you can send me your sheet and i can implicate the formula for you

    Teshi
    I have a folder with subfolders containing excel files. I wanted to count the number of files in the subfolders if the file meets the criteria. here's the path for my folder C:\My Documents\Mainfolder. If you refer to the attached file, you can see the main folder, subfolders and its criteria. For the criteria of subfolders, I wanted to count the files in the subfolder if the file contains the value of 100, 99, 98 or 97.

    Please let me know if its unclear.

    Bdw I'm using excel 03 at the office. I just created the file in excel in 2007 as I at my house right now. thanks
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: count the number of files in a specified folder

    Please could someone help me with my problem? need this on monday. Thanks

  6. #6
    Registered User
    Join Date
    05-22-2009
    Location
    UK
    MS-Off Ver
    Excel 2000,2003 and regretably 2007
    Posts
    77

    Re: count the number of files in a specified folder

    I have entered some dummy data on sheet 2 just to test this, the forumla I have used is in Sheet1!B5:
    Please Login or Register  to view this content.
    This will look at the data on sheet2 for file names containing your criteria in the adjacent cell e.g. Sheet1!B5 looks on Sheet2 for any files containing the number in Sheet1!A5, this works off of a principle of wildcards any issues please message again

    Teshi

  7. #7
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: count the number of files in a specified folder

    Quote Originally Posted by teshiburu1988 View Post
    I have entered some dummy data on sheet 2 just to test this, the forumla I have used is in Sheet1!B5:
    Please Login or Register  to view this content.
    This will look at the data on sheet2 for file names containing your criteria in the adjacent cell e.g. Sheet1!B5 looks on Sheet2 for any files containing the number in Sheet1!A5, this works off of a principle of wildcards any issues please message again

    Teshi
    Hi, i think your formula looks only for data in an excel file. What I need is to count the files if it meet the criteria. thanks

  8. #8
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: count the number of files in a specified folder

    bump this thread.

  9. #9
    Registered User
    Join Date
    03-31-2004
    Location
    Toronto, Canada
    MS-Off Ver
    2003/2007
    Posts
    36

    Re: count the number of files in a specified folder

    The code below search for files in your folder and it will populate the column A of Sheet 2 with the file names.

    In the attached file I have revised your table a bit to get the countif to work for different folders.

    Also note that this will only work in 2003 version. 2007 version do not support Filesearch. To get the same result in 2007 try
    http://support.microsoft.com/kb/185601/

    Please Login or Register  to view this content.
    hope this is what you want!
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Manila philippines
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: count the number of files in a specified folder

    Thanks for the file. I tried the file that you provided and it search for the filename. But what i wanted is to search for the value not the filename itself. ex. file(a).xls contains 100
    Last edited by shg; 06-04-2009 at 12:15 AM. Reason: deleted spurious quote

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: count the number of files in a specified folder

    bambino, please don't quote whole posts. It just clutters the forum.
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Registered User
    Join Date
    03-31-2004
    Location
    Toronto, Canada
    MS-Off Ver
    2003/2007
    Posts
    36

    Re: count the number of files in a specified folder

    Hi Bambino
    to search a value within the file you have to open and close each file.....which slows down the process. I am not aware of doing it without opening a file.

    Assuming that the value you want to check is in same cell on same sheet in every file, use the following code.

    Replace SHEET_NAME and CELL_ADDRESS per your need

    Please Login or Register  to view this content.

    If the value doesn't changes overtime for a file, I had suggest to place that value in the filename and run the previous code. It's much faster and simpler.

    Let me know if it doesn't work for you.
    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1