Someone asked a similar question on the Macworld forums, and with some help from a friend, we managed to come up with a UNIX command string that will return the answer. Say you wish to count all the files in the folder "Stuff" stored on your desktop. Simply type the following into the Terminal:
% cd ~/DesktopThis will return a count all files, including invisibles and the top level "Stuff" folder itself. If you just want to see the visible files, use:
% find "Stuff/" | wc -l
% find "Stuff/" \! -name ".*" | wc -lI'm not sure if this is the most efficient means of answering the question, but it seems to work reasonably quickly and it was accurate on all the folders I tested it on. Any other alternatives, in either the Finder or the Terminal?
If you'd like to know more about how the command works, or how to create a shortcut to make it easier to use in the future, read the rest of the article.
Here's how these commands work to return the number of files. Keep in mind I'm relatively inexperienced with UNIX, so please, help me correct any errors in my explanation!
There are two commands being used here, combined to get the result we're looking for. First, find returns a list of all files in the specified folder that match our criteria. In the first example, there are no criteria, so a list of all files is returned. In the more complex second example, the criteria is \! -name ".*". The \! means "not" (the \ is needed so the shell will not try to interpret the !). The -name ".*" means "name starts with a dot". Taken together, the critera is "not name starts with dot", so basically, return a list of all visible files.
This result is passed (via the pipe (|) symbol) to wc, or word count. With the -l option, wc simply returns the number of lines in what it received. Since it received a listing of filenames, it returns the number of lines in that listing.
To make the command easier to use in the future, simply make an alias out of it (see this hint for an explanation of aliases in OS X; read the comments for the proper directory structure). The alias version of the command is slightly different, as you need to double-escape the "!" that is being used for "not":
alias fc 'find \!:1 \\! -name ".*" | wc -l'You can change fc to whatever you like, of course. Store this in aliases.mine in ~/Library/init/tcsh, and then (after opening a new Terminal) you can just type "fc name_of_folder" (assuming you are in the parent directory which contains "name_of_folder").
I'm open to suggestions to make this easier or faster ... anyone want to wrap a quick Cocoa shell around this to make a drag-and-drop GUI app for counting files??

