Skip to content

Instantly share code, notes, and snippets.

@catalli
Created September 21, 2023 22:17
Show Gist options
  • Save catalli/e53cf42c54b9ebd0fe1a536c60184ed3 to your computer and use it in GitHub Desktop.
Save catalli/e53cf42c54b9ebd0fe1a536c60184ed3 to your computer and use it in GitHub Desktop.
Quick and dirty shell utility for non-destructively mass-setting metadata on a music album in a folder
#! /bin/bash
echo -n "Name of artist: "
read ARTIST
echo -n "Name of album: "
read ALBUM
echo -n "Year of album: "
read YEAR
FILES=$(ls $1 | grep -Ei ".(mp3|flac|opus|wav|m4a|ogg)")
mkdir "$1/$ALBUM"
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
trap 'IFS=$SAVEIFS; exit 1;' INT
for f in $FILES
do
echo "For track filename $f"
echo -n "Track title for $f: "
read TITLE
echo -n "Track No. for $f: "
read TRACK
ffmpeg -i "$1/$f" -metadata artist="$ARTIST" -metadata album="$ALBUM" -metadata date="$YEAR" -metadata track="$TRACK" -metadata title="$TITLE" -codec copy "$1/$ALBUM/$f"
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment