PDA

View Full Version : [SOLVED] BASH esacping long filenames



martinjh99
January 9th, 2011, 08:22 AM
Given this BASH script to dump the audio from FLV files as mp3s it doesnt work on files with spaces in...

How do I get it to handle space in filenames?



#!/bin/bash

OUTPUTDIR="mp3/"

for FILE in *flv; do

ffmpeg -i $FILE -acodec libmp3lame -ab 256k -ac 2 -ar 44100 $OUTPUTDIR$FILE.mp3

done

andrew.46
January 9th, 2011, 10:03 AM
Perhaps the following small variations might help:



#!/bin/bash

OUTPUTDIR="mp3"

for FILE in *.flv; do

ffmpeg -i "$FILE" -acodec libmp3lame -ab 256k -ac 2 -ar 44100 $OUTPUTDIR/"${FILE%.flv}.mp3"

done


Andrew

martinjh99
January 9th, 2011, 11:15 AM
Bingo - Thanks mate!