diff --git a/set_genre_flacs.sh b/set_genre_flacs.sh new file mode 100755 index 0000000..d75e0dd --- /dev/null +++ b/set_genre_flacs.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Check for required arguments +if [ $# -ne 2 ]; then + echo "Usage: $0 \"GENRE Name\" /path/to/directory" + exit 1 +fi + +genre="$1" +target_dir="$2" + +# Check if directory exists +if [ ! -d "$target_dir" ]; then + echo "Error: '$target_dir' is not a valid directory." + exit 1 +fi + +# Ensure metaflac is installed +if ! command -v metaflac &> /dev/null; then + echo "Error: 'metaflac' is not installed. Please install it first." + exit 1 +fi + +# Recursively find and tag FLAC files +find "$target_dir" -type f -iname "*.flac" | while IFS= read -r flac; do + echo "Tagging '$flac' with GENRE=$genre" + metaflac --remove-tag=GENRE "$flac" + metaflac --set-tag="GENRE=$genre" "$flac" +done + +echo "Genre tagging complete." +