Cut the caulk and paint between the shoe molding and the baseboard as well as between the baseboard and the wall with a utility knife. This prevents the wood from splitting when you pry off the molding, and it protects the drywall.
Tap a rigid metal putty knife between the shoe molding and the baseboard, using a hammer, and pry the shoe molding out. As soon as the gap is wide enough, wedge in a pry bar and continue prying until the nearest nails pop loose.
Work your way toward the end of the piece of molding, prying in this way. When the end is loose, pull it out. The other end of the piece of molding should separate from the baseboard. If not, work toward that end with the pry bar.
Pry off the baseboard using a 6-inch drywall knife. It puts less pressure on the wall than a putty knife and protects the drywall. Start prying in front of a stud because the baseboard is probably nailed to the wall studs. Locate the studs with the help of a stud finder.
Pry next to a nail until the head of the nail pops out. Grip the head with pliers or with a claw hammer and pry it out. Work your way from the middle of each piece toward one end and then toward the other.
Number the pieces of baseboard and shoe molding as you go if you plan to reuse them. Numbering and stacking them in order helps you remember where they go.