I have a bunch of MP3 files and I have their paths grouped in a text file. Is it possible to join the relevant MP3 files based on the paths in the text file?
Asked
Active
Viewed 2,558 times
3
-
http://askubuntu.com/a/20514/18665 – bmaupin Sep 03 '13 at 15:26
3 Answers
5
One possible approach would be to use cat
:
$ cat example1 example 2 > output
or
$ cat example* > output
This will join any two files together - not sure what it will do to the ID3 metadata though.

Jonathon
- 2,481
-
This produces non standard MP3 files, i.e. the ID3 tags are getting ruined. How do I correct the tags after using this method? – oshirowanen Oct 24 '10 at 14:11
-
-
1
I personally liked mp3wrap
because it is more powerful and the size of the final file is three times less then the file merged with cat
command.

Bakhtiyor
- 12,254
1
There are at least a couple of tool: mpgtx
and quelcom
.
You can see their descriptions through any package manager, for example:
apt-cache show mpgtx quelcom

enzotib
- 93,831
-
I can't seem to figure out how to use these. I have tried man, but there is not example usage section. – oshirowanen Oct 24 '10 at 10:22
-
qmp3join: http://manpages.ubuntu.com/manpages/lucid/man1/qmp3join.1.html
Basic usage is: qmp3join -o output.mp3 file1 file2...
It should be possible to automate the list of files based on the text file.
– Jonathon Oct 24 '10 at 11:33 -
@Jonathon:
(IFS=$'\n'; qmp3join -o output.mp3 $(cat list.txt))
will pass each line of list.txt as a parameter. ($''
is bash syntax, but you can do the same in other shells.) The IFS change is necessary for any filenames that might contain spaces (which is common for music), otherwise it's not needed. – Oct 24 '10 at 22:20 -
@Roger Pate:
$()
, without double quotes, already removes newlines, andcat
is not needed:qmp3join -o output.mp3 $(< list.txt)
– enzotib Oct 25 '10 at 05:43 -
@enzotib: As I said, the change in IFS is necessary with a list.txt that contains one filename per line and where the filenames contain spaces. Using cat or < is just personal preference here. – Oct 25 '10 at 06:33
-
@Roger Pate: ok, I missed the spaces thing, but cat or < is not only matter of personale preferences, because with cat one spawn a further unnecessary process that can be avoided. – enzotib Oct 25 '10 at 08:45
-
@enzotib: Here it is personal preference, as this will be run manually and rarely (not that another process often matters). I trust anyone in a situation where that matters to know enough to look for and change it themselves, and don't mention the difference unless I'm teaching someone how to deal with that situation; instead sticking to more familiar syntax like "cat file" and "command < redirect". – Oct 25 '10 at 08:51
-
@Roger Pate: btw, it works also without IFS and using double quotes: "$(< list.txt)" – enzotib Oct 25 '10 at 08:52
-
@enzotib: No, it doesn't work: http://codepad.org/HyTzKvoI (showargs is my program to print each argument). Did you test with a single-line file? – Oct 25 '10 at 08:57
-
@Roger Pate: I don't know what your showargs do, but for me it works, also for a single line file – enzotib Oct 25 '10 at 09:15
-
@enzotib: Note "$(...)" is a single argument, even if there are multiple lines, and this definitely does not work. I don't know of any packaged program that does showarg's (very simple) job, that's why I wroite it. – Oct 25 '10 at 09:32
-
@Roger Pate: ok, i'm convinced (this is my showargs: http://pastebin.ca/1972596), sorry to take your time. – enzotib Oct 25 '10 at 09:42
-
@enzotib: No problem; I really wish there was an easier solution than changing IFS. You should post that showargs as an answer. :) – Oct 25 '10 at 09:47
-