2

I've:

/home/wms/mp3/

and

/home/wms/tmp/

Inside ~/tmp my script:

#!/bin/bash
br=64
for a in "$1"*.mp3 ;
do ffmpeg -i "$a" -ar 44100 -ab $br "$br""_tmp/${a%.*} ["$br"].mp3" ; done

I do:

/home/wms/tmp/./script.sh /home/wms/mp3/

How I handle $1?

because "@1" concides with /home/wms/mp3/first1

${a%.*} cuts extension file

but the path is not correct: this script runs only if I runs it inside ~/mp3

2

I use basename $a to extract the name of file, and then build the path with the temporal directory:

#!/bin/bash
br=64
mkdir -p _tmp
for a in "$1"*.mp3 ; do
aux=$(basename ${a})
ffmpeg -i "$a" -ar 44100 -ab $br "$br""_tmp/${aux%.*}_["$br"].mp3" 
done
  • 2
    Exactly is: aux=$(basename "$a") this keep spaces inside filename – Pol Hallen Dec 26 '14 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.