Dominic Knight [2017-06-25 15:35:46+01] wrote: > To convert a series of .flac files to .mp3 files I attempted to use the > following line; > >> $ find -name "*.flac" -exec bash -c 'ffmpeg -i "{}" -y -acodec > libmp3lame -ab 320k "${0/.flac}.mp3"' {} \;
The arguments for "bash -c" go like this: bash -c '...' name one two three And in '...' the arguments are in variables $0 (=name), $1 (=one), $2 (=two), $3 (=three) etc. So: find -name "*.flac" -exec \ bash -c 'ffmpeg -i file:"$1" -c:a libmp3lame -ab 320k -y file:"${1%.flac}.mp3"' \ foo {} \; Note the "foo": it is saved to $0 ("shell's name") and and then the actual filename is in usual first positional parameter $1. We also want to have explicitl "file:" protocol with ffmpeg so that any "something:" prerix in filename is not interpreted as a protocol name. (See "man ffmpeg-protocols".) But here's another way without double quoting: while read -r -d $'\0' input; do ffmpeg -i file:"$input" -c:a libmp3lame -ab 320k \ -y file:"${input%.flac}.mp3" done < <(find . -name '*.flac' -print0) -- /// Teemu Likonen - .-.. <https://keybase.io/tlikonen> // // PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///
signature.asc
Description: PGP signature