rendered paste body#!/bin/shusage(){ echo "Usage: $0 <file.ape>" echo "Usage: $0 <directory>" exit 1}process_file(){ [ "{$1%.ape}" != "$1" ] || usage local PCMFILE="${1/%.ape/.wav}" local FLACFILE="${1/%.ape/.flac}" if mac "$1" "$PCMFILE" -d; then if flac --output-name="$FLACFILE" "$PCMFILE"; then rm -f "$PCMFILE" fi rm -f "$1" fi}process_directory(){ local f for f in "$1"/*.ape; do echo "$f" process_file "$f" done}[ $# -eq 1 ] || usage[ -f "$1" ] && process_file "$1"[ -d "$1" ] && process_directory "$1"