First, shift PORTD to the right two, so bit 7 becomes bit 5, bit 6 becomes bit 4, and so on:
(PORTD >> 2)
Then, clear all the bits you don't want (everything except bits 4 and 5). Do this by bitwise-anding each bit with zero, except bits 4 and 5:
(PORTD >> 2) & 0b00110000
Finally, assign this to PORTB. If you want to replace the contents of PORTB with this result, just use normal assignment. If you want to combine the present contents of PORTB with the result, you would do a bitwise-or assignment:
e: Magician, I think that would keep bits 3 and 4 (assuming we're counting from bit zero).
e2: Oops, pyro is right - you need to clear bits 4 and 5 in PORTB before assignment.