You are not logged in.
Pages: 1
Googling comes up with a lot of stuff, but I see nothing Linux specific, so I'm gonna ask here:
I have 2 songs, and they're both mp3s. I want them to be combined into one mp3, so that there is absolutely NO silence in between the two parts. Hopefully there is an automated way to do this, but I can do it manually over some time if I need to. If my question isn't clear, sorry, tell me and I'll try to explain better.
Thanks in advance.
Offline
You can do it with mp3wrap (http://mp3wrap.sourceforge.net or in AUR: http://aur.archlinux.org/packages.php?ID=14603). It's a small but very good program.
Daniel
Offline
Perhaps "cat" command can do it. A quick google search looked like it was so. I've use cat to join video files before if memory serves.
Offline
Perhaps "cat" command can do it. A quick google search looked like it was so. I've use cat to join video files before if memory serves.
cat does work with simple mpeg files. Although sometimes it can be weird about timestamps. I think that mp3 are fine though:
cat first.mp3 second.mp3 last.mp3 > new.mp3
Offline
Okay, cat seems to work, and i have mp3wrap installed too. The songs have a little skip in them, but that's not cat's fault, and I can live with it. Now here's my problem, and I am not savvy enough to figure it out. I now have a good number of songs in two different parts in one folder. I would love a script to be able to fix this, without me having to type cat a thousand times. The songs have a number at the beginning, then the name, and then the second part has "REQUESTED ...", then .mp3. I would guess there is a way to automate this cat'ing process instead of me having to do it hand by hand, judging by this. I hate to ask people to do it for me, but how could I do this?
Offline
If you'll give a couple example filenames (anonymize them if you want, just leave the relevant indicators where they are), I (or someone else who gets to it first) can whip up a shell loop to do it.
Offline
Alright
0212_Metallica - Hero of the Day.mp3
0213_Metallica - Hero of the Day - -Requested-.mp3
are a couple.
And if it's not too much, rm'ing the ones that I've cat'ed (which I could do if it was just the Requested part, but getting the one right before that I wouldn't know how to do) out of this folder would be cool too.
Thanks a lot.
Offline
mkdir requested merged
mv *-Requested-.mp3 requested
for file in *.mp3 ; do
cat "$file" "requested/${file%.mp3} - -Requested-.mp3" > "merged/$file"
done
rm -r *.mp3 requested
That should work. The result will end up in the "merged" directory. Careful about the rm at the end, you probably want to make sure the merged files are all okay before you delete the originals.
Last edited by skymt (2008-11-09 21:17:34)
Offline
Question before I try: If there are songs in this folder that aren't split into two parts, it won't touch them will it? (well, the last command will, but other than that?)
EDIT: Nevermind, I took the ones without a requested to a different folder. Now it is close to working, but it returns:
cat: requested/0066_Led Zeppelin - Immigrant Song - -Requested-.mp3: No such file or directory
This makes since, as 0066 is the original, but 0067 is the one it should be looking for. It needs to add one to that number, then it would work.
Last edited by voteforpedro36 (2008-11-09 21:28:19)
Offline
Question before I try: If there are songs in this folder that aren't split into two parts, it won't touch them will it? (well, the last command will, but other than that?)
It would. Here's a version that wouldn't.
mkdir first second merged
for file in *-Requested-.mp3 ; do
mv "$file" second
mv "${file%-Requested-.mp3}" first
done
# Check here to make sure the correct files are in the correct directories
for file in first/*.mp3 ; do
cat "$file" "second/${file%.mp3} - -Requested-.mp3" > "merged/$file"
done
rm -r first second
Offline
^^ See edit.
Offline
Oh right, sorry. My eyes skipped over the number difference.
mkdir first second merged
for file in *-Requested-.mp3 ; do
mv "$file" second
mv "${file%-Requested-.mp3}" first
done
# Check here to make sure the correct files are in the correct directories
for first in first/*.mp3 ; do
firstnum=${first%%_*}
firstnum=${firstnum#*/}
secondnum=$(( 10#$firstnum + 1 ))
secondnum=$(printf "%04i" $secondnum)
second=second/$secondnum_*
cat "$first" "$second" > "merged/$first"
done
rm -r first second
I really hope that works. Shell arithmetic is fun.
Offline
Lol I see. Now here's a problem. Nothing gets moved to 'first'. I have to change
for file in *-Requested-.mp3 ; do
mv "$file" second
mv "${file%-Requested-.mp3}" first
done
the first *-Requested-.mp3 to *-Requested*.mp3 (not all of them end with that), and more things get moved to second, and less errors. If I try to change the second -Requested- in that code to -Requested* again, it throws more 'no such directory' at me, and still nothing in 'first'. If I understand correctly, what that second mv does is take $file, which has *Requested*.mp3 at the end, and take everything after Requested off, and move those files to 'first'. But it forgets about the *.mp3, and the numbers, as it tells me:
mv: cannot stat `0218_Guns N\' Roses - Civil War - ': No such file or directory
I'm guessing it wants to move it to first. What it needs to move, though, is a file called 0217_Guns N\' Roses - Civil War.mp3. Sorry if none of this made sense. It's getting close though, thanks a lot.
Last edited by voteforpedro36 (2008-11-09 22:17:52)
Offline
Ouch. Looks like the names are less consistent than I knew. Is everything in the right folder now?
Offline
Okay done. The ones with -Requested* are in second, the ones without it but that need to be cat'ed are in first. I couldn't fix the problemso I just moved them manually to first.
EDIT: Tried running the second half:
bash: merged/first/0189_The Who - Baba O'Riley.mp3: No such file or directory
On and on. I know there is no such file or directory, I'm trying to make it
Last edited by voteforpedro36 (2008-11-09 23:09:23)
Offline
The script really depends on being run from the right directory. Are you running it from the top directory, that is, the one containing first, second, and merged?
Offline
The script really depends on being run from the right directory. Are you running it from the top directory, that is, the one containing first, second, and merged?
Yes, just
for first in first/*.mp3 ; do
firstnum=${first%%_*}
firstnum=${firstnum#*/}
secondnum=$(( 10#$firstnum + 1 ))
secondnum=$(printf "%04i" $secondnum)
second=second/$secondnum_*
cat "$first" "$second" > "merged/$first"
done
though, as I would suppose I have done the first part already.
Last edited by voteforpedro36 (2008-11-09 23:32:20)
Offline
for first in first/*.mp3 ; do
firstnum=${first%%_*}
firstnum=${firstnum#*/}
secondnum=$(( 10#$firstnum + 1 ))
secondnum=$(printf "%04i" $secondnum)
second=second/$secondnum_*
cat "$first" "$second" > "merged/${first#*/}"
done
That should work. Sorry for the delay, I was AFK due to sleep.
Offline
cat: second/*: No such file or directory
This results in the first file just being moved to the merged folder. I have a feeling it's getting really close though, thanks a ton.
Offline
Pages: 1