port clean --all installedwas failing at a port and aborted (I may have been playing with the ports folder a bit much) without reaching the other, less fortunately alphabetised, ports.
Using the arguably misguided patch approach, I wrote a perl script to solve my immediate problem rather than the underlying one. It individually cleans each port, continuing if some fail. Apparently, MacPorts has a safeguard for ports that need their folder, as it refused to clean them without adding an argument. The script below can be used safely, and saved me a few hundreds of "Mebibytes" of space.
Just save the script to a file, make it executable, and sudo it.
#!/usr/bin/perl -w
my @items = `port echo installed`;
my %clean;
foreach $line (@items)
{
if ($line =~ /([a-zA-Z0-9_-]+).*?/)
{
system("port", "clean", "--all", $1) unless ($clean{$1});
$clean{$1} = 1;
}
}