#!/bin/bash cd $1 for d in */; do album="${d%/}" # Remove leading numbering: "001 - " album=$(echo "$album" | sed -E 's/^[0-9]+[[:space:]]*-[[:space:]]*//') album=$(echo "$album" | sed -E 's/^\([^)]*\)[[:space:]]*//; s/[[:space:]]*\([^)]*\)$//') # Remove all (...) groups album=$(echo "$album" | sed -E 's/$$[^)]*$$//g') # Remove all [...] groups album=$(echo "$album" | sed -E 's/$$[^]]*$$//g') # Remove standalone years album=$(echo "$album" | sed -E 's/[[:space:]]+[12][0-9]{3}//g') # Collapse multiple spaces and trim album=$(echo "$album" | sed -E 's/[[:space:]]+/ /g; s/^ //; s/ $//') echo "Setting album: $album" cd "$d" || continue for x in *; do [ -f "$x" ] || continue kid3-cli -c "set album \"$album\"" -c save "$x" done cd .. done