How to list all inactive modules on a multisite? I have kept several hundreds of modules in my D6 Drupal multisite. I have had them there so that when I need any of them I don't have to download it first - I just go to /admin/build/modules and switch on what I want. 

The problem is that that list of modules takes ages so long to load that the work becomes inefficient. Also Drupal monitoring services, such as the excellent droptor.com, have a hard time (literally, very time consuming calls) to retrieve the current status of each site. The PHP memory allocation is stretched as well.

In short, I am looking for a programmatic way to select and then delete all inactive and uninstalled modules in any site of a Drupal 6 multisite.

I know there are complications -- module folders often do not correspond exactly to their module names (e.g. module "CCK Privacy" is in folder "privacy"). Also, some modules might actually be in subdirectories in cases where one project ships several modules at once. The problem is especially confounded in case of multisites, where some modules might be inactive for one of the sites, but they need to be in the directory because some of the other sites use them.

(There was an interesting thread on this at http://groups.drupal.org/node/123179 but it did not offer any practical solution for multisites.)
I am not sure of a way to do this programatically, but you could install http://drupal.org/project/enabled_modules and cross-reference the lists.