Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count all files inside a folder, its subfolder and all . The count should not include folder count [closed]

How to count all files inside a folder, its subfolder and all . The count should not include folder count.

I want to do it in MAC

like image 348
Peter Avatar asked Mar 19 '12 11:03

Peter


People also ask

How do I count files in a folder and subfolders?

Browse to the folder containing the files you want to count. Highlight one of the files in that folder and press the keyboard shortcut Ctrl + A to highlight all files and folders in that folder. In the Explorer status bar, you'll see how many files and folders are highlighted, as shown in the picture below.

Is there a way to count the number of files in a folder?

Use File Explorer Open the folder and select all the subfolders or files either manually or by pressing CTRL+A shortcut. If you choose manually, you can select and omit particular files. You can now see the total count near the left bottom of the window. Repeat the same for the files inside a folder and subfolder too.


2 Answers

find . -type f | wc -l will recursively list all the files (-type f restricts to only files) in the current directory (replace . with your path). The output of this is piped into wc -l which will count the number of lines.

like image 55
Jeff Foster Avatar answered Sep 20 '22 08:09

Jeff Foster


Find all files under myfolder and count them using wc. This works on linux:

find myfolder -type f | wc -l

like image 36
perreal Avatar answered Sep 20 '22 08:09

perreal