Ugh. MP3 has horrible sound quality. Be warned that you
must set some specific, minimum sound quality requirements (sample rate, bit depth, compression level) and then also spot check the sample before you play a sample for others. Otherwise you can get burned badly by some M$ users that way, they make unusable files sounding worse than tin speakers through a garden hoses, you get the blame. Ogg is not great but
worlds better.
You kind of addressed this but perhaps you have original files in a lossless format which you can use to produce a new MP3 or other format file? That can be scripted too.
If you really want to do that with MP3 instead of with a lossless format, you could try
mp3wrap or even
ffmpeg. Either might work.
Code:
stat --printf '%n\0' *.mp3 | shuf --zero-terminated | xargs --null mp3wrap one-big-file.mp3
or maybe
Code:
tfile=$(tempfile)
stat --format "file '%n'" *.mp3 | shuf > $tfile
ffmpeg -f concat -safe 0 -i $tfile -codec copy one-big-file.mp3
test -f $tfile && rm $tfile
I'm not sure how either affect the sound quality. It'll be the same as before or worse, probably the same. Either can work from a file.
Another question, now that the sound quality is gone through the very use of MP3, do you want to try to keep the metadata? If so, you may to write a script to extract it from each file and then read it in. Though,
mp3wrap appears it might save the metadata somehow and it warns you with new metadata that you have a concatenated file.
ffmpeg seems to just use the metadata from the first file only.