I'm looking for a specific directory file count that returns a number. I would type it into the terminal and it can give me the specified directory's file count.
I've already tried echo find "'directory' | wc -l"
but that didn't work, any ideas?
You can see the file count by enabling Status Bar in Finder. To do this, click View -> Show Status Bar on the menu bar, or press Command + /. When you click "Show Status Bar", does a status bar appear at the bottom of Finder? If so, what does it display (if not the item count)?
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.
Using the ls Command. The ls command lists the directories and files contained in a directory. The ls command with the -lR options displays the list (in long format) of the sub-directories in the current directory recursively.
You seem to have the right idea. I'd use -type f
to find only files:
$ find some_directory -type f | wc -l
If you only want files directly under this directory and not to search recursively through subdirectories, you could add the -maxdepth
flag:
$ find some_directory -maxdepth 1 -type f | wc -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With