Scrape off any items that are stuck on the surface of the shelves using a putty knife.
Sand the entire surface of the bookshelf using a medium coarse sandpaper. You do not have to sand off all the old paint, but just ensure there is none that is loose or peeling.
Wipe the entire bookshelf with mineral spirits applied with an old rag. The mineral spirits will clean the surface and remove any particles left behind from the sanding process.
Paint the bookshelf using a latex paint and a 4-inch paintbrush. Start at the top of the bookshelf and work your way down so that any drips can be brushed out. Paint the shelves from back to front so that you are not reaching over already painted areas.
Let the paint dry for 24 hours and apply a second coat if needed.