WordPress – Bulk remove categories

One might think this should be an easy task to do on such succesful CMS as WordPress is.
But it turns out that there is no native way how to bulk remove categories, especially not from custom post types, or pages as you sometimes might end up with.. Yes, pages can have categories as well.

And so to get rid of the categories from posts, pages, what ever you have.. do this:

$args =array(
   'post_type' => 'page', // set what ever post type you like
   'posts_per_page' => -1, // process all 
   'post_status' => 'any' // any status, published, draft, .. 

$posts = get_posts($args);
   foreach($posts as $p) {
   wp_remove_object_terms( $p->ID, 10, 'category' ); // post id, term id, taxonomy name

Put it for example in to your index.php, run it one, delete the code.
That is all there is to it.

Such an basal function and nowhere to be found.