If you want an incredibly difficult way, you could do it with XML-RPC. You can get a list of all the files in a namespace (dokuwiki.getPagelist) then save an empty page for each (wiki.putPage). You can get a list of all media (wiki.getAttachments) then delete them (wiki.deleteAttachment). If it's in use, the delete will fail.
https://www.dokuwiki.org/devel:xmlrpc
I agree this functionality in general should be on the roadmap, a namespace management config tool. I have multiple namespaces, over a dozen users, hundreds of pages and hundreds of media files. I also use XML-RPC and scripts to check in source code files to the wiki.
In the meantime, as for cleaning up old media files, you might try the plugin unusedmedias (I haven't tried yet).
https://www.dokuwiki.org/plugin:unusedmedias
Sample PHP functions to manipulate a namespace (Print your own web UI, "are you sure?" prompts, validation. Don't forget your ACLs restrict your RPC calls from touching protected namespaces. WARNING DokuWiki will parse nested namespaces, so if you mean nuke your root namespace, all the sub-namespaces will go too. But that's what "revert" is for :) )
include('/usr/lib64/php/xmlrpc.inc');
include('../wiki/conf/local.php');
function listfiles($strNamespace) {
$c = new xmlrpc_client('/wiki/lib/exe/xmlrpc.php', 'localhost');
// dont validate certicate anyways
$c->setSSLVerifyPeer(0);
// create the XML message to send
$m = new xmlrpcmsg('dokuwiki.getPagelist');
$m->addParam(new xmlrpcval($strNamespace));
$m->addParam(new xmlrpcval(array()));
// send the message and wait for response
$r = $c->send($m, 5, 'https');
// did we fail? die!
if($r == false) die('error');
// if we got an error, the page did not save!
if($r->faultCode()){
$output = "<p>we got an error trying to read namespace: $strNamespace</p>\n";
$output .= "<p>" . $r->faultCode() . "=" . $r->faultString() . "</p>\n";
echo $output;
return false;
} else {
echo "<h1>namespace: $namespace</h1>\n";
$v = php_xmlrpc_decode($r->value());
foreach ($v as $value) {
$output .="<pre>" . $value['id'] . "</pre>\n";
}
}
return $output;
}
function listfilesarray($strNamespace) {
$aryReturn = array();
$c = new xmlrpc_client('/wiki/lib/exe/xmlrpc.php', 'localhost');
// dont validate certicate anyways
$c->setSSLVerifyPeer(0);
// create the XML message to send
$m = new xmlrpcmsg('dokuwiki.getPagelist');
$m->addParam(new xmlrpcval($strNamespace));
$m->addParam(new xmlrpcval(array()));
// send the message and wait for response
$r = $c->send($m, 5, 'https');
// did we fail? die!
if($r == false) die('error');
// if we got an error, the page did not save!
if($r->faultCode()){
$output = "<p>we got an error trying to read namespace: $strNamespace</p>\n";
$output .= "<p>" . $r->faultCode() . "=" . $r->faultString() . "</p>\n";
echo $output;
return false;
} else {
$v = php_xmlrpc_decode($r->value());
foreach ($v as $value) {
array_push($aryReturn, $value['id']);
}
}
return $aryReturn;
}
function savetxt($strArticle,$strText) {
$c = new xmlrpc_client('/wiki/lib/exe/xmlrpc.php', 'localhost');
// dont validate certicate anyways
$c->setSSLVerifyPeer(0);
// create the XML message to send
$m = new xmlrpcmsg('wiki.putPage');
$m->addParam(new xmlrpcval($strArticle));
$m->addParam(new xmlrpcval($strText));
$m->addParam(new xmlrpcval(array("sum" => new xmlrpcval("Created programatically")),"struct"));
// send the message and wait for response
$r = $c->send($m, 5, 'https');
// did we fail? die!
if($r == false) die('error');
// if we got an error, the page did not save!
if($r->faultCode()){
$output = "<p>we got an error trying to save: $strArticle</p>\n";
$output .= "<p>" . $r->faultCode() . "=" . $r->faultString() . "</p>\n";
echo $output;
return false;
} else {
return true;
}
}
function delpage($strArticle) {
return savetxt($strArticle,'');
}
function delnamespace($strNamespace) {
$files = listfilesarray($strNamespace);
foreach ($files as $page) {
$ret = delpage($page);
}
}