dot

packages and services management
Log | Files | Refs | README

commit 42a5807a8965941ce05401aa1cbe3787dd112c93
parent c842e7a5e7a95f37fcfdbba241b6cfdb785764eb
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 23 Feb 2018 02:14:13 +0100

mv-flac to rename files after their tags

Diffstat:
Abin/mv-flac | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/bin/mv-flac b/bin/mv-flac @@ -0,0 +1,23 @@ +#!/bin/sh -e + +# usage: mv-flac <file> + +# Rename a flac file according to its tags, extracted via the +# metaflac tool. The naming scheme is: +# "artist/year-album/[discno-]trackno-title.flac" + +al="$(metaflac --show-tag=ALBUM "$1" | sed 's/^[^=]*=//')" +ar="$(metaflac --show-tag=ARTIST "$1" | sed 's/^[^=]*=//')" +da="$(metaflac --show-tag=DATE "$1" | sed 's/^[^=]*=//')" +path="$(printf %s/%s-%s "$ar" "$da" "$al" | tr -s ' ' -)" + +tr="$(metaflac --show-tag=TRACKNUMBER "$1" | sed 's/^[^=]*=//; s/\/*//')" +di="$(metaflac --show-tag=DISCNUMBER "$1" | sed 's/^[^=]*=//; s/\/*//')" +dt="$(metaflac --show-tag=DISCTOTAL "$1" | sed 's/^[^=]*=//; s/\/*//')" +ti="$(metaflac --show-tag=TITLE "$1" | sed 's/^[^=]*=//')" +name="$(printf %02d-%s.flac "$tr" "$ti" | tr -s '/ ' -)" + +[ "$di" = "$dt" ] || name="$di-$name" + +mkdir -p "$path" +ln "$1" "$path/$name"