Count the files in a directory
Count the files in a directory with ls -A | wc -l, or with find when names may contain newlines. A plain ls -1 skips every hidden file.
You need the number of entries in one directory, and the obvious command undercounts when dotfiles are present.
mkdir demo && cd demo
touch a b c .hidden
ls -1 | wc -l
ls -A | wc -l
find . -mindepth 1 -maxdepth 1 | wc -l
touch "$(printf 'two\nlines')"
ls -A | wc -l
find . -mindepth 1 -maxdepth 1 -printf x | wc -c3
4
4
6
5ls -1 leaves out names that start with a dot, and -A brings them back without the . and .. entries that -a adds. Counting lines is wrong when a name holds a newline, as the fifth command shows with a file called "two" newline "lines". find -printf x prints one character per entry no matter what the name is, so counting characters is exact. Options are in the GNU find manual.
-printf is a GNU find extension. On BSD use find . -mindepth 1 -maxdepth 1 -exec echo x ';' | wc -l, or accept that newline in names is rare enough in your data to ignore. The count includes directories, not just regular files.