Created
March 10, 2025 20:43
-
-
Save deviationist/d2e6bc3e14f6a682cfe926304ea580a2 to your computer and use it in GitHub Desktop.
File counter grouped by file extension (v2), tailored for audio files. Will now ignore files and folders starting with a dot (.).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "File type count:" | |
fileExtensions=( aiff mp3 wav m4a flac alac ) | |
totalFileCount=$(find . -type f \( -name "*.aiff" -o -name "*.mp3" -o -name "*.wav" -o -name "*.m4a" -o -name "*.flac" -o -name "*.alac" \) -not -path "*/\.*" | wc -l) | |
for fileExtension in "${fileExtensions[@]}" | |
do | |
fileCount=$(find . -type f -name "*.${fileExtension}" -not -path "*/\.*" | wc -l) | |
if [ $totalFileCount -eq 0 ]; then | |
roundedPercent=0 | |
else | |
percent=`echo "$fileCount * 100 / $totalFileCount" | bc -l` | |
roundedPercent=`printf "%.0f" $percent` | |
fi | |
echo "${fileExtension}: ${fileCount} files (${roundedPercent}%)" | |
done | |
echo "" | |
echo "File extensions found in directory (excluding hidden files/directories):" | |
echo $(find . -type f -not -path "*/\.*" -name '*.*' | sed 's|.*\.||' | sort -u) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment