Created
June 2, 2023 22:10
-
-
Save deviationist/a6f8b4a8e6c140107759a90938c7d758 to your computer and use it in GitHub Desktop.
File counter grouped by file extension, tailored for audio files.
This file contains 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 . -name "*.aiff" -o -name "*.mp3" -o -name "*.wav" -o -name "*.m4a" -o -name "*.flac" -o -name "*.alac" | wc -l) | |
for fileExtension in "${fileExtensions[@]}" | |
do | |
fileCount=$(find . -name "*.${fileExtension}" | wc -l) | |
percent=`echo "$fileCount * 100 / $totalFileCount" | bc -l` | |
roundedPercent=`printf "%.0f" $percent` | |
echo "${fileExtension}: ${fileCount} files (${roundedPercent}%)" | |
done | |
echo "" | |
echo "File extesions found in directory:" | |
echo $(find . -type f -name '*.*' | sed 's|.*\.||' | sort -u) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment