View Single Post
  #2   (View Single Post)  
Old 4th August 2015
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Dutchman living in the UK
Posts: 2,198
Default

Code:
${f/%flac/m4a}
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
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote