Donald Trump has moved to settle scores with the law firms that have represented his political foes or dragged him into court on civil or criminal charges.