Created
July 8, 2010 22:59
-
-
Save tobbez/468774 to your computer and use it in GitHub Desktop.
Create a list of albums from flac tags
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
#!/bin/bash | |
# | |
# Created by tobbez | |
# | |
# Issues: | |
# Does not handle Various Artists-albums properly | |
function get_artist () { | |
metaflac --show-tag=ARTIST "$1" | cut -d= -f2 | |
} | |
function get_album () { | |
metaflac --show-tag=ALBUM "$1" | cut -d= -f2 | |
} | |
if [ ! $# -eq 2 ] | |
then | |
echo "Usage: ${0} <output file> <directory>" | |
exit | |
fi | |
output="${1}" | |
scan_dir="${2}" | |
output_arg="-o "${output}"" | |
if [ "${output}" == "-" ] | |
then | |
output_arg="" | |
fi | |
num_files=`find "${scan_dir}" -type f -iname '*.flac' | wc -l` | |
let scanned_files=0 | |
find "${scan_dir}" -type f -iname '*.flac' | while read file | |
do | |
echo "`get_artist "${file}" | tr '/' ' '` / `get_album "${file}" | tr '/' ' '`" | |
let scanned_files=$scanned_files+1 | |
echo -ne "\r${scanned_files}/${num_files} scanned..." >&2 | |
if [ $scanned_files -eq $num_files ] | |
then | |
echo >&2 | |
fi | |
done | sort -t "/" -k 2 -u $output_arg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment