Add script to set flac tags from filename
This commit is contained in:
30
flac_set_tags_from_filename.sh
Normal file
30
flac_set_tags_from_filename.sh
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# sets the tags for songs (FLAC files) according to their name
|
||||||
|
# the name should be in the format: <TRACK NR>. <ARTIST> - <TITLE>.flac.
|
||||||
|
# so for example: 01. Artist - Title.flac
|
||||||
|
|
||||||
|
for file in *.flac; do
|
||||||
|
name="${file%.flac}"
|
||||||
|
|
||||||
|
if [[ "$name" =~ ^([0-9]+)\.\ (.+)\ -\ (.+)$ ]]; then
|
||||||
|
track="${BASH_REMATCH[1]}"
|
||||||
|
artist="${BASH_REMATCH[2]}"
|
||||||
|
title="${BASH_REMATCH[3]}"
|
||||||
|
|
||||||
|
echo "Tagging: $file"
|
||||||
|
echo " TRACKNUMBER=$track"
|
||||||
|
echo " ARTIST=$artist"
|
||||||
|
echo " TITLE=$title"
|
||||||
|
|
||||||
|
metaflac --remove-tag=TRACKNUMBER \
|
||||||
|
--remove-tag=ARTIST \
|
||||||
|
--remove-tag=TITLE \
|
||||||
|
--set-tag="TRACKNUMBER=$track" \
|
||||||
|
--set-tag="ARTIST=$artist" \
|
||||||
|
--set-tag="TITLE=$title" \
|
||||||
|
"$file"
|
||||||
|
else
|
||||||
|
echo "Skipping (unexpected format): $file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user