LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   file divided into multiple pieces (https://www.linuxquestions.org/questions/linux-newbie-8/file-divided-into-multiple-pieces-4175455371/)

wuthering 03-24-2013 11:43 AM

file divided into multiple pieces
 
Hi everybody,

Someone has split my audio class lessons and some songs I put on my smartphone into multiple pieces: I guess he or she used the "split utility" to do this in order to make me angry but how could I use the "join utility" to mend the files?

Thanx,

Wuthering

TobiSGD 03-24-2013 12:11 PM

There is no join utility, but you can easily use cat, like this:
Code:

cat part1 part2 part3 part4 >joined_file

colucix 03-24-2013 12:12 PM

What are the names of the pieces? Can you post an example? If you are sure they have been divided using the split utility, you can assemble pieces using cat. Just pay attention to put the names of the pieces in the correct order. Example:
Code:

cat xaa xab xac xad xae xaf > output_file
or
Code:

cat file.part1 file.part2 file.part3 file.part4 > output_file
the result will have exactly the same sequence of bytes as the original file. If you're sure they have been divided by split!

Edit: beaten by TobiSGD! ;)

shivaa 03-24-2013 12:38 PM

@TobiSGD/colucix:
I am just currious... Can cat create a full music file (i.e. may be mp3 clips) from pieces of file?

colucix 03-24-2013 12:55 PM

Quote:

Originally Posted by shivaa (Post 4917802)
@TobiSGD/colucix:
I am just currious... Can cat create a full music file (i.e. may be mp3 clips) from pieces of file?

Of course. It simply put bytes in sequence and it doesn't make any difference among file types. On the other hand, every file is a pure sequence of bits: it is the software that interpret the sequences in one way or another. cat simply concatenates the pieces and doesn't make any attempt to interpret them, nor changes them in any way.

shivaa 03-24-2013 01:06 PM

Quote:

Originally Posted by colucix (Post 4917817)
Of course. It simply put bytes in sequence and it doesn't make any difference among file types. On the other hand, every file is a pure sequence of bits: it is the software that interpret the sequences in one way or another. cat simply concatenates the pieces and doesn't make any attempt to interpret them, nor changes them in any way.

Agree. That means, if I want to combine two mp3 files or clips i.e. song1.mp3 and song2.mp3, I can use cat to combine them... right?
Code:

~$ cat song1.mp3 song2.mp3 > newsong.mp3

colucix 03-24-2013 01:25 PM

Yes and no. The situation you describe is totally different from joining pieces coming from one original file. A mp3 file has a header that contains information about the bit-rate, the audio codec and so on. If you concatenate two mp3 using cat, this information is not updated and it remains related to the first file, not to the resulting mp3. Nevertheless an audio player can still play the file and you will listen to two songs in sequence. However I think it is a matter of luck in this case! ;)

TobiSGD 03-24-2013 02:13 PM

Quote:

Originally Posted by colucix (Post 4917838)
Yes and no. The situation you describe is totally different from joining pieces coming from one original file. A mp3 file has a header that contains information about the bit-rate, the audio codec and so on. If you concatenate two mp3 using cat, this information is not updated and it remains related to the first file, not to the resulting mp3. Nevertheless an audio player can still play the file and you will listen to two songs in sequence. However I think it is a matter of luck in this case! ;)

I wouldn't be too sure that an audioplayer will play both parts of such a file. MP3 files can have two blocks of metadata, one in the last 128 bytes of the file (ID3v1) and one in the beginning of the file (size dependend on content, up to 16 so called frames with a maximum of 16MB each, so maximum 256MB, ID3v2). I wouldn't expect any audioplayer to handle files correctly were these chunks of data appear on places were they are not expected, for example when you concatenate a file with ID3v1 and a file with ID3v2 in a way that the metadata is in the middle of the new file. With files without metadata colucix should be correct, since MP3 files have not only one header, but many of them, so that a change in bitrate or other variables shouldn't make any differences.

MP3 file structure: https://en.wikipedia.org/wiki/Mp3#File_structure
ID3 tags: https://en.wikipedia.org/wiki/ID3

colucix 03-24-2013 02:34 PM

Thanks for the clarification, TobiSGD!
Quote:

Originally Posted by TobiSGD (Post 4917861)
I wouldn't expect any audioplayer to handle files correctly were these chunks of data appear on places were they are not expected, for example when you concatenate a file with ID3v1 and a file with ID3v2 in a way that the metadata is in the middle of the new file.

Indeed, I tried with two files having the same ID3 version (ID3v2). This probably explains the "matter of luck" I mentioned in my previous post! :)

wuthering 03-25-2013 02:20 PM

@colucix :is the any other utility to split a mp3 file and corrupt a song and how can I get the information about the corrupted file I want to mend to check if it is therefore the split utility used by the guy?

tomorrow, I will be able to give you more details as I don't have the cable to connect my smartphone with the computer.

Thanx everybody for your useful answers.

wuthering.

TobiSGD 03-25-2013 02:32 PM

Instead of the split utility you also can use any audio editor to split the file into multiple smaller ones. In this case you would even be able to play any chunk independent from the others.
To test if the person that did this really used split (or a similar working tool) the best and simplest option is to just launch the cat command to join them and try if you can play it.

wuthering 04-12-2013 02:37 PM

to TobiSGD:
as I am a newbie on linux, I don't know how to use the cat utility , I mean : I transfered the corrupted files from my smartphone to my computer and I put it in /home.
But what shall I write in the shell ? I must give details : for example it is a file of german class lessons but for each file , it is complete indeed but when I listen to it, it is as if it is splited, I don't know if I am clear enough: it it as if you have your mp3 cd device that bugs when you listen to the music. Do you understand ?

TobiSGD 04-13-2013 03:05 PM

Try it with this command
Code:

cat file1 file2 file3 file4 > newfile
Of course you have tp use the real filenames here.

wuthering 04-13-2013 03:29 PM

you did not understand <moderated>

TobiSGD 04-13-2013 05:21 PM

If I misunderstood you then please try to explain what you mean in a different way. If you have problems to do that because English is not your native language it may be easier for you to e-mail me and explain your problem in German (since you mentioned German lessons).

Also, please remove those insults, this forum is not a place for that.


All times are GMT -5. The time now is 03:15 AM.