Script to batch convert sound files

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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?










share|improve this question



















  • 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 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














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?










share|improve this question



















  • 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 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












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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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












  • 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 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







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










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





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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





    share|improve this answer


























      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





      share|improve this answer
























        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





        share|improve this answer














        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






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 4 at 18:35









        Ali Razmdideh

        3,18011436




        3,18011436










        answered Mar 4 at 18:32









        John Rose

        43031022




        43031022



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491