bash - jasper-zanjani/dotfiles GitHub Wiki
Extracting audio from mp4 files in a directory
# Using variable substitution to replace on file extension with another
for f in *.mp4; do ffmpeg -i $f ${f/.mp4/.wav}
Less gracefully:
for f in *.mp4
do
# Find length of filename, removing 4 for the filename extension
l=$(expr length "$f" - 4)
# Slice string to remove the file extension, then concatenate extensions again
# using brace expansion to form two quoted strings from the original filename
echo \"${f::$l}{.mp4\",.wav\"} | xargs ffmpeg -i
done