shithub: rc

ref: c1a707427fbbb5129e467516fc671e976ee3e398
dir: /alac2flac/

View raw version
#!/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
	}
}