In both of those sentences, 'only' is used as a means to express want. 欲しい。
I want to buy a CD, but because I don't have any money, I won't.
I wanted to go with him, but because I was busy that day, I didn't.
'Only' makes it easier to express these things. It is explaining the ONLY reason things are not done.
I'd buy a CD, only I don't have any money (and there's nothing else preventing me from buying a CD).
I would have gone with him, only I was too busy that day (and there was nothing else preventing me from going with him).
'But' can also be used in place of 'only' in these sentences, but it would take out that small meaning that I just explained.