[FFmpeg-user] Converting to mp3 in batch

James Darnley james.darnley at gmail.com
Tue Jun 14 20:12:50 CEST 2011


On 14/06/2011, Dotan Cohen <dotancohen at gmail.com> wrote:
> Hi all, I have many files that I need to convert to mp3 to play on my
> portable device. The files are in many different formats, and have
> spaces and unicode characters in the file names. I'm not well versed
> in awk or bash, I'm piecing this together from google searches.
>
> My current idea for changing all the files is this:
> $ mkdir mp3
> $ for file in *; do `ffmpeg -i $file mp3/$file.mp3`;done
>
> However, it fails on files with spaces in the filenames. Furthermore,
> it renames files by appending .mp3 to the end, but it leaves the old
> filename extension intact: name.amr becomes name.amr.mp3. What code
> should I be using to alleviate these too issues?

Quote the filename.
Use the appropriate expansion feature for your shell.  Bash: ${file/%.*/.mp3}


More information about the ffmpeg-user mailing list