How can I count the number of files in a folder and subfolder without including the number of subfolders in the number?

Hi - Does anyone know an easy way to count the number of files in a folder and subfolders without including the folders and subfolders in the number? I am aware of Cmd-i but it seems that this includes the folders and subfolders in the number. I just would like to see the number of files.

MacBook Pro with Retina display, OS X Yosemite (10.10.5)

Posted on Sep 13, 2015 12:19 PM

Reply
4 replies

Sep 13, 2015 9:51 PM in response to davidjp227

Hi David.


The finder method wouldn't work for all file types, and it's a bit on the cumbersome side to use.


Instead I propose using a standard method to count file which works under both Linux and OSX, and you would do that from the Terminal.


1. Start the terminal application

by default it will start in your home folder

2. Use cd /Volumes/volumename/folder/subfolder to change the folder to the one you need the count on. (if your folder is in your home folder, simply cd testfolder would get you to it)

3. Run the following:

find . -type f | wc -l

This searches inside the current folder (that's what the . stands for) for all files, and counts them.


You can of course replace the . with

find /Volumes/volumename/folder/subfolder -type f | wc -l

if you want to have a handy command to go back and use again and again.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I count the number of files in a folder and subfolder without including the number of subfolders in the number?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.