Join Mp3 From The Command Line - gHacks Tech News

Join Mp3 From The Command Line

Lots of tools- like the previously reviewed Mp3 Merge -  can join multiple mp3 files into a single mp3 file that contains all audio of all files joined in the process.

Mp3 files but also files with the ogg extension can be concatenated easily because of the way the data is structured. The following command line argument will not work with many other file types like those created by Microsoft Office, but they work fine for mp3 and ogg files.

Best of all, it is part of all versions of Windows which means that you don't need to download and run an extra program for that anymore provided you don't mind working on the command line.

Only one line of code is needed to join multiple mp3 files: copy /b *.mp3 c:\new.mp3. That's all there is needed. The /b parameter ensures that the files are copied in binary format. *.mp3 defines the source directory of the files.

You can easily add a drive and folder structure in front. The wildcard * defines that all mp3 will be joined alphanumerically by the command. It is possible to limit the files by adding letters or numbers to the command, e.g. m*.mp3 to join all mp3 starting with the letter m.

join mp3

The last part c:\mp3 defines the target directory for the newly created file as well as its name. A possibility to join files with different file names is also available. Simply use the command copy /b file1.mp3 + aaa.mp3 + r3f.mp3 c:\new.mp3 for this. You may use wildcards as well for the process.

Several applications like Audacity can also be used to merge music files. Mp3 Direct Cut is another one for the purpose.

While it may take longer to use the command line for the purpose of merging mp3 files, it is something that is always available if you are working on a Windows PC. All the other tools require you to run software to merge the files, and that option may not always be available.

Summary
Join Mp3 From The Command Line
Article Name
Join Mp3 From The Command Line
Description
The tutorial explains how to join mp3 audio files from the Windows command line using the built-in copy tool.
Author

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:

Comments

  1. Anon said on November 18, 2008 at 4:55 am
    Reply

    Linux & Mac:

    cat track1.mp3 track2.mp3 > compilation.mp3

  2. smerball said on November 18, 2008 at 5:12 am
    Reply

    linux
    cat *.mp3 > newfile.mp3

    darn, late again

  3. Rob Blake said on November 18, 2008 at 5:45 am
    Reply

    This method won’t work on an ipod without first stripping the mp3 files of all mp3 id3 tags. Look at http://eyed3.nicfit.net/ to remove the id3 tags before performing this command.

    Also, make sure that all mp3s were encoded with the same bit-rate settings. You can see this with the eyeD3 tool as well.

  4. JKT said on November 18, 2008 at 6:52 am
    Reply

    Any tips on getting this to work with .doc files? I’m no command line pro, so I need someone to spell it out. All that seems to happen is that the first file in the series gets copied to the new location. Files are not joined.

  5. alex said on November 18, 2008 at 10:10 am
    Reply

    @JKT, There is no way to get this work with doc. because doc isn’t a stream (like mp3). doc is an format with header and ending, so you can’t combine the raw files.

  6. bretagne said on November 18, 2008 at 11:24 am
    Reply

    thanks to the tip!

  7. john said on November 18, 2008 at 3:50 pm
    Reply

    I use a dos mp3 splitter for audio books… (use soundtaxi on audible to strip DRM leaving you with one large file) I use this for my mp3 cd player in the car

    http://mp3splt.sourceforge.net/mp3splt_page/home.php

    Here is a batch file to split an audio book from one large file to cd size chunks, and then dechunk those to individual chapters (detects blank sound and splits)

    mp3splt.exe “%1” -t 78.0 -d “%1_” -o “[email protected]

    cd “%1_”
    for %%a in (*.mp3) do mp3splt.exe “%%a” -s -p min=2.5 -d “%%a_” -o “[email protected]
    del *.mp3

  8. Dan Philpott said on November 20, 2008 at 9:38 pm
    Reply

    I’d also mention that using “copy /b” isn’t a good practice as it merges the ID3 information along with the rest of the MP3 audio data. This means the MP3 player has bad (non-audio) data included in the audio stream. Depending on the software/firmware reading the file this may or may not be a problem during playback.

    Unfortunately this is also the fastest way I know to merge mp3 files.

    A good practice is to make a copy of the MP3s you want to merge in a separate folder then use ID3remover to strip the ID3 information.

    Another trick which is especially handy with multi-CD audiobooks is to put the MP3’s for each disk into subfolders of an otherwise empty folder (i.e., Windows InternalsWindows Internals CD1, Windows InternalsWindows Internals CD2). The files should have the track number listed first so they sort in the order they should be played. At that point execute the following command within the root folder:

    for /f “delims==” %A in (‘dir /ad /b’) do copy /b “%A*.mp3” “%A.mp3”

    Presto, one MP3 file per folder.

  9. simo said on December 6, 2008 at 10:12 pm
    Reply
    1. KirkD said on January 25, 2012 at 5:32 am
      Reply

      Great recommendation simo. Shuangs Audio Joiner worked perfectly!

      > simo says:
      > December 6, 2008 at 10:12 pm
      > http://www.shuangsoft.com/Shuangs_Audio_Joiner.asp

  10. YouCanDoIT said on July 4, 2009 at 1:58 am
    Reply

    Excellent – thanks for the tip, works perfectly

  11. Terrence said on March 19, 2011 at 11:33 pm
    Reply

    This is definitely the easiest way, but as Dan explains it doesn’t produce a “clean” file because it joins all the ID3 tags together inside the MP3 data. It makes files that will have the wrong song length in iTunes and iPod, and seeking to a different point in the song won’t work. Plus, your file will have the ID3v1 tag of the last file you join but the ID3v2 tag of the first file you join! (because ID3v1 tags go at the end of files)

    Here’s a better explanation, that also goes over a better method:
    http://lyncd.com/2011/03/lossless-combine-mp3s/

    Something else to check out is Merge MP3, which is a Windows GUI to do the same thing.

  12. Paul said on February 21, 2012 at 12:00 pm
    Reply

    Great tip!

  13. Matt Gerrans said on July 4, 2013 at 1:29 am
    Reply

    Thanks for the tip! I would not have imagined that it would be so easy to join mp3 files; make sense for text or other simple formats, but I didn’t think of trying it since I assumed an mp3 was comprised of the header with metadata followed by the audio stream. One would guess that the metadata would make noise, but apparently the format (as in ignores) accommodates it.

  14. Robo Roxy said on November 11, 2013 at 5:35 am
    Reply

    thankyou for the tip ;)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.