dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 35e1059d8d3dcb67cc1795f2f9764f91c15de388
parent 19c3e013e70ec6474c035529e3cc1b4f3670caf1
Author: hhvn <dev@hhvn.uk>
Date:   Mon,  5 Sep 2022 16:05:17 +0100

Add scripts for formating filenames based on metadata

Diffstat:
A.scripts/tag/fileformat | 18++++++++++++++++++
A.scripts/tag/fileformatmv | 19+++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/.scripts/tag/fileformat b/.scripts/tag/fileformat @@ -0,0 +1,18 @@ +#!/bin/rc +# +# Formats the names of files in my preferred way. +# + +fn sigexit { + rm $tmp +} + +tmp = /tmp/$pid.tags +for (f in $*) { + tag/get $f > $tmp + track = `$nl{grep '^track:' < $tmp | sed 's/^track: 0*//;s~/.*$~~'} + title = `$nl{grep '^title:' < $tmp | sed 's/^title: //'} + ext = `$nl{echo $f | sed 's/.*\.//' | tr '[:upper:]' '[:lower:]'} + dir = `$nl{dirname $f} + printf '%s/%02d %s.%s\n' $dir $track $title $ext +} diff --git a/.scripts/tag/fileformatmv b/.scripts/tag/fileformatmv @@ -0,0 +1,19 @@ +#!/bin/rc +# +# tag/fileformat, but renames them +# + +for (old in $*) { + if (echo $old | grep -vEi '\.(mp3|flac|opus|m4a)$' >/dev/null) { + printf 'NOT AUDIO:\t%s\n' $old >[1=2] + continue + } + + new = `$nl{tag/fileformat $old} + + if (echo $new | grep '/[0-9][0-9] ..*\..*$' >/dev/null && echo $new | grep -v '/00' >/dev/null) { + mv -v $old $new + } else { + printf 'CHECK FAILED:\t%s\t%s\n' $old $new >[1=2] + } +}