ref: f7bf533d38cbdfc107e90812256d3c2bbaf3592b
parent: 68a262deb38ce842a2f13f297ca18d74b36d4b2f
author: sl <sl@x1yg3>
date: Wed Jun 25 20:47:01 EDT 2025
add alac2flac alac2mp3 ape2flac flac24216 flacsplit flac2alac flac2mp3
--- /dev/null
+++ b/alac2flac
@@ -1,0 +1,25 @@
+#!/bin/rc
+# Convert ALAC to FLAC using ffmpeg, then delete the ALAC files.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: Running alac2flac converts files in the current directory.
+# The -r flag recurses into subdirectories.
+# Dependencies:
+# https://ffmpeg.org
+# https://9fans.github.io/plan9port/
+# http://plan9.stanleylieber.com/rc/crip
+rfork e
+path=$PLAN9/bin:$PATH
+formats='m4a|M4A'
+fn walk{ du $1 | awk '{print $2}' | sed 's/^\./'^$"1^'/'}
+if(~ $1 -r){
+ for(i in `{walk `{pwd} | sort -f}){ echo $"i && cd $"i && alac2flac}
+ exit
+}
+if(ls | grep -s -e $"formats){
+ crip -n # normalize file names for plan 9
+ for(i in `{ls | grep -e $"formats}){
+ f=`{echo $"i | sed 's/\.m4a//'}
+ ffmpeg -i $"i -f flac $"f.flac &&
+ rm -f $"i
+ }
+}
--- /dev/null
+++ b/alac2mp3
@@ -1,0 +1,28 @@
+#!/bin/rc
+# Convert ALAC to MP3 using mplayer and lame, then delete the ALAC files.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: Running alac2flac converts files in the current directory.
+# The -r flag recurses into subdirectories.
+# Dependencies:
+# http://www.mplayerhq.hu/design7/dload.html
+# https://lame.sourceforge.io/
+# https://9fans.github.io/plan9port/
+# http://plan9.stanleylieber.com/rc/crip
+rfork e
+path=$PLAN9/bin:$PATH
+formats='m4a|M4A'
+fn walk{ du $1 | awk '{print $2}' | sed 's/^\./'^$"1^'/'}
+if(~ $1 -r){
+ for(i in `{walk `{pwd} | sort -f}){ echo $"i && cd $"i && alac2mp3}
+ exit
+}
+if(ls | grep -s -e $"formats){
+ crip -n # normalize file names for plan 9
+ for(i in `{ls | grep -e $"formats}){
+ mplayer -quiet -vo null -vc dummy \
+ -af volume'='0,resample'='44100:0:1 \
+ -ao pcm:waveheader:file'='$"f.wav $"i &&
+ lame --quiet -m -s -h -b 320 -V0 --vbr-new $"f.wav $"f.mp3 &&
+ rm -f $"f.wav
+ }
+}
--- /dev/null
+++ b/ape2flac
@@ -1,0 +1,18 @@
+#!/bin/rc
+# Convert APE to FLAC using ffmpeg, bchunk, and flac,
+# then delete the intermediate WAV files.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: Running alac2flac converts files in the current directory.
+# Dependencies:
+# https://9fans.github.io/plan9port/
+# http://he.fi/bchunk
+# https://ffmpeg.org
+# https://www.xiph.org/flac
+rfork e
+ffmpeg -i $2 out.wav &&
+bchunk -w out.wav $1 FILE &&
+rm -f out.wav &&
+for(i in FILE*.wav){
+ flac --best $i &&
+ rm -f $i
+}
--- /dev/null
+++ b/flac2alac
@@ -1,0 +1,14 @@
+#!/bin/rc
+# Convert FLAC to ALAC using ffmpeg.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: Running flac2alac converts files in the current directory.
+# Dependencies:
+# https://ffmpeg.org
+# https://9fans.github.io/plan9port/
+for(i in *.flac){
+ file=`{echo $"i | sed 's/[^a-zA-Z0-9]/_/g; s/_flac$/\.flac/g'}
+ if(! ~ $file $i){
+ cp $"i $file && rm -f $"i
+ }
+ ffmpeg -i $file -c:a alac `{echo $file | sed 's/\.flac/\.m4a/'}
+}
--- /dev/null
+++ b/flac2mp3
@@ -1,0 +1,19 @@
+#!/bin/rc
+# Convert FLAC to MP3 using lame.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: Running flac2mp3 converts files in the current directory.
+# Dependencies:
+# https://lame.sourceforge.net
+# https://9fans.github.io/plan9port/
+for(i in *.flac){
+ file=`{echo $"i | sed 's/[^a-zA-Z0-9]/_/g; s/_flac$/\.flac/g'}
+ if(! ~ $file $i){
+ cp $"i $file && rm -f $"i
+ }
+ flac -d $file
+}
+for(i in *.wav){
+ lame -b 320 $i &&
+ rm -f $i &&
+ mv $i.mp3 mp3/
+}
--- /dev/null
+++ b/flacsplit
@@ -1,0 +1,9 @@
+#!/bin/rc
+# Split single FLAC into multiple files based on .cue sheet using shntool.
+# This program is intended to run on a UNIX-like operating system.
+# Usage: flacsplit file.cue file.flac
+# Dependencies:
+# https://9fans.github.io/plan9port/
+# http://shnutils.freeshell.org/shntool
+rfork e
+shnsplit -o flac -f $1 -t '%n - %t' $2
--
⑨