The beetle ate everything except the front cover of volume one and the back cover of volume four.
The thickness of the front cover of volume one and the back cover of volume four = 0.5 cm + 0.5 cm = 1 cm.
Total distance covered by the books = 4 x 8cm = 32 cm.
Therefore, total distance travelled by the beetle is 32 - 1 = 31 cm.