Script to batch convert sound files
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
As Sound Converter now hangs for me in Xenial (since a few days), I wanted to write a bash script to simulate it:
I want to convert a few *.wav files in a directory specified by the variable wav_path to 'equivalent' mp3 files in an existing directory specified by mp3_path. I've got the following so far, though it's incorrect:
for i in "$wav_path"/*.wav;
do
lame -h -b 192 "$i" "$i%.wav.mp3"
done
What should I change this to?
bash
 |Â
show 3 more comments
up vote
0
down vote
favorite
As Sound Converter now hangs for me in Xenial (since a few days), I wanted to write a bash script to simulate it:
I want to convert a few *.wav files in a directory specified by the variable wav_path to 'equivalent' mp3 files in an existing directory specified by mp3_path. I've got the following so far, though it's incorrect:
for i in "$wav_path"/*.wav;
do
lame -h -b 192 "$i" "$i%.wav.mp3"
done
What should I change this to?
bash
1
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
1
Please edit your question with this new information - including the definitions ofwav_path
andmp3_path
which appear to be missing from the code you posted.
â steeldriver
Mar 4 at 16:48
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10
 |Â
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
As Sound Converter now hangs for me in Xenial (since a few days), I wanted to write a bash script to simulate it:
I want to convert a few *.wav files in a directory specified by the variable wav_path to 'equivalent' mp3 files in an existing directory specified by mp3_path. I've got the following so far, though it's incorrect:
for i in "$wav_path"/*.wav;
do
lame -h -b 192 "$i" "$i%.wav.mp3"
done
What should I change this to?
bash
As Sound Converter now hangs for me in Xenial (since a few days), I wanted to write a bash script to simulate it:
I want to convert a few *.wav files in a directory specified by the variable wav_path to 'equivalent' mp3 files in an existing directory specified by mp3_path. I've got the following so far, though it's incorrect:
for i in "$wav_path"/*.wav;
do
lame -h -b 192 "$i" "$i%.wav.mp3"
done
What should I change this to?
bash
bash
edited Mar 4 at 13:29
steeldriver
63.3k1198167
63.3k1198167
asked Mar 4 at 13:10
John Rose
43031022
43031022
1
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
1
Please edit your question with this new information - including the definitions ofwav_path
andmp3_path
which appear to be missing from the code you posted.
â steeldriver
Mar 4 at 16:48
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10
 |Â
show 3 more comments
1
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
1
Please edit your question with this new information - including the definitions ofwav_path
andmp3_path
which appear to be missing from the code you posted.
â steeldriver
Mar 4 at 16:48
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10
1
1
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
1
1
Please edit your question with this new information - including the definitions of
wav_path
and mp3_path
which appear to be missing from the code you posted.â steeldriver
Mar 4 at 16:48
Please edit your question with this new information - including the definitions of
wav_path
and mp3_path
which appear to be missing from the code you posted.â steeldriver
Mar 4 at 16:48
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10
 |Â
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
Finally got it working. Relevant code is:
for i in "$wav_path"/*.wav;
do
filename="$i##*/"
filename="$filename%.*"
lame -h -b 192 "$i" "$mp3_path"/"$filename".mp3
done
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Finally got it working. Relevant code is:
for i in "$wav_path"/*.wav;
do
filename="$i##*/"
filename="$filename%.*"
lame -h -b 192 "$i" "$mp3_path"/"$filename".mp3
done
add a comment |Â
up vote
0
down vote
Finally got it working. Relevant code is:
for i in "$wav_path"/*.wav;
do
filename="$i##*/"
filename="$filename%.*"
lame -h -b 192 "$i" "$mp3_path"/"$filename".mp3
done
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Finally got it working. Relevant code is:
for i in "$wav_path"/*.wav;
do
filename="$i##*/"
filename="$filename%.*"
lame -h -b 192 "$i" "$mp3_path"/"$filename".mp3
done
Finally got it working. Relevant code is:
for i in "$wav_path"/*.wav;
do
filename="$i##*/"
filename="$filename%.*"
lame -h -b 192 "$i" "$mp3_path"/"$filename".mp3
done
edited Mar 4 at 18:35
![](https://i.stack.imgur.com/k7xZK.png?s=32&g=1)
![](https://i.stack.imgur.com/k7xZK.png?s=32&g=1)
Ali Razmdideh
3,18011436
3,18011436
answered Mar 4 at 18:32
John Rose
43031022
43031022
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1011774%2fscript-to-batch-convert-sound-files%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You should explain in what way it is incorrect - what do you want it to do? what actually happens?
â steeldriver
Mar 4 at 13:30
I've moved on a little. I'm now having problem with:
â John Rose
Mar 4 at 15:37
I've moved on a little. I'm now having problem with: for i in "$wav_path"/*.wav; do basename "$i" .wav lame -h -b 192 "$i" "$mp3_path/filename.mp3" done It should convert all .wav files in directory wav_path and put them as .mp3 files in directory mp3_path. It actually does e.g. Encoding wav/Track 14.wav to mp3/filename.mp3.
â John Rose
Mar 4 at 16:19
1
Please edit your question with this new information - including the definitions of
wav_path
andmp3_path
which appear to be missing from the code you posted.â steeldriver
Mar 4 at 16:48
It's difficult to edit questions with much info as there is a low limit on the amount of comment allowed in a message. It would help if this site allowed attached files. However, I shall try.
â John Rose
Mar 4 at 17:10