Merge mp3 files UNIX way, with cat

root's picture

The other day I had few mp3 files, converted from a VIDEO_TS and because the video was split in 5 parts, the audio result was also 5 mp3 files:

florian@osx$ ls -la mp3/*mp3
-rw-r--r--  1 florian  florian  42494976 Feb  2 10:50 mp3/VTS_01_1.VOB.ff.mp3
-rw-r--r--  1 florian  florian  42511104 Feb  2 10:51 mp3/VTS_01_2.VOB.ff.mp3
-rw-r--r--  1 florian  florian  11082240 Feb  2 10:53 mp3/VTS_01_3.VOB.ff.mp3
-rw-r--r--  1 florian  florian  42494976 Feb  2 10:52 mp3/VTS_02_1.VOB.ff.mp3
-rw-r--r--  1 florian  florian  14993280 Feb  2 10:53 mp3/VTS_02_2.VOB.ff.mp3

Al I had to do now was to find a way to put them together. Of course, you can find over the internet various software that can do this, free or not. But if you have unix around, why bother? Use cat! Yes, I am not joking.

florian@osx$ cat mp3/* > alltogether.mp3
florian@osx$ ls -la alltogether.mp3
-rw-r--r--  1 florian  florian  153576576 Feb  2 12:29 alltogether.mp3

I had my mp3 files in order and there was no problem using only one command but if you want to merge them one by one, in a different order, you can do this:

florian@osx$ cat mp3/VTS_01_1.VOB.ff.mp3 > alltogether.mp3
florian@osx$ cat mp3/VTS_01_2.VOB.ff.mp3 >> alltogether.mp3
florian@osx$ cat mp3/VTS_01_3.VOB.ff.mp3 >> alltogether.mp3
florian@osx$ cat mp3/VTS_02_1.VOB.ff.mp3 >> alltogether.mp3
florian@osx$ cat mp3/VTS_02_2.VOB.ff.mp3 >> alltogether.mp3
florian@osx$ ls -la alltogether.mp3
-rw-r--r--  1 florian  florian  153576576 Feb  2 12:37 alltogether.mp3

Do note: there is a difference between > and >>. First redirection is erasing everything from the target and the second one is adding the content at the end of the file.

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content