xxxxxxxxxx
# Use this command
ls /etc | wc -l
# replace /etc with the path to the directory you want to work with
xxxxxxxxxx
find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done
xxxxxxxxxx
# Method A
import os
dir_path = r'E:\account'
count = 0
for path in os.listdir(dir_path):
if os.path.isfile(os.path.join(dir_path, path)):
count += 1
print('File count:', count)
# Method B
import os
dir_path = r'E:\demos\files_demos\account'
print(len([entry for entry in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, entry))]))
xxxxxxxxxx
#Find all File's name that starts with chapter-CHAPTER in a Directory
count=$(echo $PATH |ls | grep '^moby-CHAPTER' | wc -l)
echo $count chapters