This will only work in certain shells, such as Bash or ksh.
1. Make sure you're using bash or ksh. I don't quite recall what /bin/sh in OpenBSD is, but IIRC is comes with *some* flavour of ksh by default.
2. Use
${f%.flac}.m4a
, which will work in all Bourne shells.
I also don't quite understand why you put everything on a single line. Don't you agree that the following is much more readable :-)
Code:
#!/bin/sh
# script using ffmpeg to convert FLAC to ALAC and use AtomicParsley to #merge
# the cover.jpg into the converted ALAC files.
for f in *.flac; do
new_file="${f%.flac}.m4a"
image="${f%.flac}.jpg"
ffmpeg \
-i "$f" \
-vf "crop=((in_w/2)*2):((in_h/2)*2)" \
-c:a alac "$new_file" \
"$image"
AtomicParsley "$new_file" --artwork "$image" --overWrite
rm "$image"
done