feat: Add function to count files by extension in current directory

This commit is contained in:
Marcus Quinn (aider)
2025-03-13 16:34:05 +00:00
parent 3f109c22f6
commit eb5b57345f

View File

@ -0,0 +1,17 @@
# Function to count files by extension in the current directory
count_files_by_extension() {
# Check if the current directory is valid
if [[ ! -d . ]]; then
echo "Error: Current directory is invalid."
return 1
fi
# Use find and awk to count files by extension
find . -type f | awk -F. '
NF>1 { ext[$NF]++ }
END {
for (e in ext) {
printf "%s: %d\n", e, ext[e]
}
}'
}