dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

dirformat (644B)


      1 #!/bin/rc
      2 #
      3 # Format a directory name as an album/release
      4 #
      5 
      6 if (!test -d $1) {
      7 	printf 'Not a directory: %s\n' $1
      8 	exit 1
      9 }
     10 
     11 p = `$nl{dirname $1}
     12 f = `$nl{find $1 -maxdepth 1 -type f -iname '*.opus' -o -iname '*.mp3' -o -iname '*.m4a' -o -iname '*.wav' -o -iname '*.flac' | head -n 1}
     13 
     14 if (~ $f ()) {
     15 	echo 'No audio files'
     16 }
     17 
     18 fn sigexit {
     19 	rm $tmp
     20 }
     21 
     22 tmp = /tmp/$pid.tags
     23 
     24 tag/get $f > $tmp
     25 album = `$nl{grep -i '^album:' < $tmp | sed 's/^[^ ]*: //' | tr / _}
     26 date = `$nl{grep -i '^date:' < $tmp | sed 's/^[^ ]*: //'}
     27 
     28 if (~ $album () || ~ $date ()) {
     29 	printf 'Insufficient metadata: %s\n' $f
     30 	exit 1
     31 }
     32 
     33 printf '%s/%s (%s)\n' $p $album $date