Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Command line converting all .wav files as a big .mp3 file

  1. #1
    Join Date
    Apr 2006
    Beans
    3,990

    Command line converting all .wav files as a big .mp3 file

    Hi all,

    What will be the command line to convert all .wav files to .mp3 files and combine all .mp3 files as a big .mp3 file?

    Thanks

    Regards

  2. #2
    Join Date
    May 2024
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Command line converting all .wav files as a big .mp3 file

    Quote Originally Posted by satimis View Post
    Hi all,

    What will be the command line to convert all .wav files to .mp3 files and combine all .mp3 files as a big .mp3 file?

    Thanks

    Regards
    This is a question simple enough for LLMs to answer, and you should consider using them in future (or at the very least, search the web). I've gone ahead and done it for you this time:

    To convert.wav files to.mp3 files in a Linux/Mac environment, you can use a command-line tool called ffmpeg. Here's a simple command to convert a single.wav file to.mp3:

    ffmpeg -i input.wav output.mp3

    Replace input.wav with the name of your.wav file and output.mp3 with the desired name for the.mp3 file.

    To convert all.wav files in a directory to.mp3, you can use a for loop in bash:

    for f in *.wav; do ffmpeg -i "$f" "${f%.wav}.mp3"; done

    This command will convert all.wav files in the current directory to.mp3.

    To combine all.mp3 files into a single.mp3 file, you can use the ffmpeg command with the -f concat option. First, create a list of.mp3 files in a text file:

    ls *.mp3 > mp3files.txt

    Next, create a new.mp3 file by combining the files listed in mp3files.txt:

    ffmpeg -f concat -safe 0 -i mp3files.txt -c copy combined.mp3

    Replace combined.mp3 with the desired name for the output file.

    Please note that you need to have ffmpeg installed on your system to run these commands. If it's not installed, you can install it using the package manager for your operating system. For example, on Ubuntu, you can use the following command to install ffmpeg:

    sudo apt-get install ffmpeg

  3. #3
    Join Date
    Apr 2006
    Beans
    3,990

    Re: Command line converting all .wav files as a big .mp3 file

    Quote Originally Posted by currentshaft View Post
    This is a question simple enough for LLMs to answer, and you should consider using them in future (or at the very least, search the web). I've gone ahead and done it for you this time:

    To convert.wav files to.mp3 files in a Linux/Mac environment, you can use a command-line tool called ffmpeg. Here's a simple command to convert a single.wav file to.mp3:

    ffmpeg -i input.wav output.mp3

    Replace input.wav with the name of your.wav file and output.mp3 with the desired name for the.mp3 file.

    To convert all.wav files in a directory to.mp3, you can use a for loop in bash:

    for f in *.wav; do ffmpeg -i "$f" "${f%.wav}.mp3"; done

    This command will convert all.wav files in the current directory to.mp3.

    To combine all.mp3 files into a single.mp3 file, you can use the ffmpeg command with the -f concat option. First, create a list of.mp3 files in a text file:

    ls *.mp3 > mp3files.txt

    Next, create a new.mp3 file by combining the files listed in mp3files.txt:

    ffmpeg -f concat -safe 0 -i mp3files.txt -c copy combined.mp3

    Replace combined.mp3 with the desired name for the output file.

    Please note that you need to have ffmpeg installed on your system to run these commands. If it's not installed, you can install it using the package manager for your operating system. For example, on Ubuntu, you can use the following command to install ffmpeg:

    sudo apt-get install ffmpeg
    Thanks for your advice.

    I have ffmpeg running here.

    $ ffmpeg -i 1.wav -i 2.wav -i 3.wav -i 4.wav output.wav
    (all .wav files in one folder)

    $ ffmpeg -i output.wav -acodec libmp3lame audio.mp3

    With 2 separate commands I can get the job done.

    Is there a (one) command to get the job done, not with pipe | command

    Thanks and regards

  4. #4
    Join Date
    May 2024
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Command line converting all .wav files as a big .mp3 file

    They are separate commands, but you can combine them with one of the following:

    command1 && command2: this will run command2 IF command1 SUCCEEDS
    command1 || command2: this will run commands2 IF command1 FAILS
    command1 ; command2: this will run command2 regardless of what happens to command1

    Hope this helps.

  5. #5
    Join Date
    Apr 2006
    Beans
    3,990

    Re: Command line converting all .wav files as a big .mp3 file

    Hi all,

    Performed following steps;
    1) #with lame command
    for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done

    2) # with ffmpeg
    ffmpeg -i "concat:1.mp3|2.mp3|3.mp3|4.mp3|5.mp3|6.mp3|7.mp3| 8.mp3|9.mp3'|10.mp3'|11.mp3" -acodec copy output.mp3

    It works, converting all .wav files to one mp3 file.

    Could it be done in ONE command?

  6. #6
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Command line converting all .wav files as a big .mp3 file

    Could it be done in ONE command?
    Yes .. as in post #4
    Remember to tag thread as SOLVED.

  7. #7
    Join Date
    Apr 2006
    Beans
    3,990

    Re: Command line converting all .wav files as a big .mp3 file

    Quote Originally Posted by dragonfly41 View Post

    Yes .. as in post #4
    Remember to tag thread as SOLVED.
    Hi@dragonfly41,

    Thanks

    Sorry, I'm searching further;
    Would there is a single command to complete 2 jobs ?

    not a command line

    Regards
    Last edited by satimis; May 27th, 2024 at 10:53 AM.

  8. #8
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Command line converting all .wav files as a big .mp3 file

    A single command .. but not by command line?

    I would use a hotkey which runs a batch of commands. Multiple ways od doing from a hot key that I have used.

    Autohotkey
    Actiona
    Albert
    etc. etc.

    Desktop automation. UI emulators.


    [POSTSCRIPT]
    Since you appear from past theads to be building some form of media studio / library I am going to suggest that you use CherryTree as your archiving tool. It is described as a rich text hierarchical notes editor .. but it is much more.

    https://github.com/giuspen/cherrytree

    You can create a hierarchy of notes with embedded CodeBoxes which you can run, while taking notes.

    I'm busy at moment but can expand later if you dig into it. Your multiple commands above can be written in embedded CodeBoxes alongside archive notes.

    My advice is to use *.ctd (XML) document mode for desktop indexing reasons which can be explained later (if you follow this route). Clue: Recoll desktop indexer.
    Last edited by dragonfly41; May 27th, 2024 at 01:20 PM. Reason: Adding CherryTree

  9. #9
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,804

    Re: Command line converting all .wav files as a big .mp3 file

    I would use Sound Exchange - a program called sox.

  10. #10
    Join Date
    Mar 2011
    Location
    U.K.
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Command line converting all .wav files as a big .mp3 file

    I have learned to use the best of multiple tools to create your own Swiss army knife.
    So combine them.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •