Skip to main content
added explanantion
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

find + ffmpeg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;
  • $0 - passed into shell command as a destination directory ~/Music_Flac/
  • $1 - passed into shell command as a filepath {}
  • bn=${1##*/} - file basename without directory path
  • bn=${bn%.*} - file basename with extension truncated
  • -loglevel 16 - set the logging level 16 used by ffmpeg

find + ffmpeg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;

find + ffmpeg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;
  • $0 - passed into shell command as a destination directory ~/Music_Flac/
  • $1 - passed into shell command as a filepath {}
  • bn=${1##*/} - file basename without directory path
  • bn=${bn%.*} - file basename with extension truncated
  • -loglevel 16 - set the logging level 16 used by ffmpeg
Typo fix
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

find + ffmpregffmpeg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;

find + ffmpreg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;

find + ffmpeg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;
Source Link
RomanPerekhrest
  • 30.9k
  • 5
  • 47
  • 68

find + ffmpreg solution:

find ~/Music -type f -iname "*.wav" -exec sh -c \
'bn=${1##*/}; bn=${bn%.*}; ffmpeg -loglevel 16 -i "$1" "${0}${bn}.flac"' ~/Music_Flac/ {} \;