Drupal - How to get list of module folders which can be deleted safely?
Use this:
drush pmi --fields=type,project,title,status,path --format=table|sort
This gives you a module list with five columns:
First is the type of project: module or theme.
Second one is the module project, for exampe views, logintoboggan, admin_menu, etc.
The third one is the installation status: enabled (in use), disabled (not in use but install info in DB) and not installed (it hasn't been installed yet or it have been already uninstalled).
Fourth column is module name. A module downloaded from drupal.org can have several modules inside (the downloaded module is the project and the inside modules are the real modules).
The fifth column is the path to the module.
With this information you can safely remove every project (second column) that all of its modules are in 'not installed' state.
For example, see this fragment list:
module job_scheduler Job Scheduler enabled sites/all/modules/contrib/job_scheduler
module job_scheduler Job Scheduler Trigger not installed sites/all/modules/contrib/job_scheduler/modules/job_scheduler_trigger
module jquery_update jQuery Update enabled sites/all/modules/contrib/jquery_update
module l10n_client Localization client enabled sites/all/modules/contrib/l10n_client
module l10n_update Localization update enabled sites/all/modules/contrib/l10n_update
module languageicons Language Icons enabled sites/all/modules/contrib/languageicons
module ldap LDAP Authentication not installed sites/all/modules/contrib/ldap/ldap_authentication
module ldap LDAP Authorization - Roles not installed sites/all/modules/contrib/ldap/ldap_authorization/ldap_authorization_drupal_role
module ldap LDAP Authorization not installed sites/all/modules/contrib/ldap/ldap_authorization
module ldap LDAP Authorization - OG not installed sites/all/modules/contrib/ldap/ldap_authorization/ldap_authorization_og
module ldap LDAP Feeds not installed sites/all/modules/contrib/ldap/ldap_feeds
module ldap LDAP Help not installed sites/all/modules/contrib/ldap/ldap_help
module ldap LDAP Query not installed sites/all/modules/contrib/ldap/ldap_query
module ldap LDAP Servers not installed sites/all/modules/contrib/ldap/ldap_servers
module ldap LDAP SSO not installed sites/all/modules/contrib/ldap/ldap_sso
module ldap LDAP Test Module not installed sites/all/modules/contrib/ldap/ldap_test
module ldap LDAP User Module not installed sites/all/modules/contrib/ldap/ldap_user
module ldap LDAP Views not installed sites/all/modules/contrib/ldap/ldap_views
module libraries Libraries enabled sites/all/modules/contrib/libraries
You can safely remove the ldap module because all modules are not installed but not job scheduler because one of its modules is enabled.
This works on Linux Machines. But you can do something similar on windows also I think.
Use the following command to get a list of disabled or uninstalled modules.
drush pml --type=Module --status="disabled,not installed" --no-core
--pipe | paste -s -d,
You will get a comma separated list like this
admin_toolbar,admin_toolbar_tools,features,features_ui,entity_browser,
entity_browser_example,config_update,content_types_full_export
If you want to remove only the uninstalled module you can remove disabled from status option in the first query.
Once you have the comma separated list of un-installed modules you can pass it on to the drush pmi query like this.
drush pmi --format=csv --fields=path
admin_toolbar,admin_toolbar_tools,features,features_ui,entity_browser,
entity_browser_example,config_update,content_types_full_export
You will get the ouput as
modules/admin_toolbar
modules/admin_toolbar/admin_toolbar_tools
modules/features
modules/features/modules/features_ui
modules/entity_browser
modules/entity_browser/modules/example
modules/config_update
modules/features_modules/content_types_full_export
You can use this to safely delete the folders :)
I have two suggestions for you on how to filter that drush command. One is with pipes and grep. The other is with the option arguments.
First off I think you want drush pml (lowercase "L", not lowercase "I").
(1) Pipes and Grep See the command below to list everything with status of "Not installed". The following may help give you a better picture of what's around your site. For example, here is what is there but "not installed" on my dev box.
$ drush pml | grep 'Not installed' | grep -v Core
Administration Actions permissions (VBO) (actions_permissions) Module Not installed 7.x-3.2
BackgroundField BackgroundField (backgroundfield) Module Not installed 7.x-1.5
Chaos tool suite Better Jump Menus (jump_menu) Module Not installed 7.x-1.4
Chaos tool suite Chaos Tools (CTools) AJAX Example (ctools_ajax_sample) Module Not installed 7.x-1.6
Chaos tool suite Chaos Tools (CTools) Plugin Example (ctools_plugin_example) Module Not installed 7.x-1.6
Chaos tool suite Custom content panes (ctools_custom_content) Module Not installed 7.x-1.6
Chaos tool suite Custom rulesets (ctools_access_ruleset) Module Not installed 7.x-1.6
Chaos tool suite Page manager existing pages (pm_existing_pages) Module Not installed 7.x-1.4
Chaos tool suite Stylizer (stylizer) Module Not installed 7.x-1.6
Chaos tool suite Term Depth access (term_depth) Module Not installed 7.x-1.6
Chaos tool suite Views content panes (views_content) Module Not installed 7.x-1.6
Taken individually that is
drush pml \ # Shows table of modules/themes and their status
| grep 'Not installed' \ # Filters for any line WITH 'Not installed'
| grep -v Core # Filters OUT any line containing string 'Core'
Given that you could do the following too :
$ drush pml | grep 'Enabled'
$ drush pml | grep 'Disabled'
(2) With options arguments to drush pml
You could also vary it up a bit with different arguments in the drush pml command
$ drush help pml
Show a list of available extensions (modules and themes).
Options:
--core Filter out extensions that are not in drupal core.
--no-core Filter out extensions that are provided by drupal core.
--package Filter by project packages. You can use multiple comma separated values. (i.e. --package="Core
- required,Other").
--pipe Returns a whitespace delimited list of the names of the resulting extensions.
--status=<disabled> Filter by extension status. Choices: enabled, disabled and/or 'not installed'. You can use
multiple comma separated values. (i.e. --status="disabled,not installed").
--type=<module> Filter by extension type. Choices: module, theme.
For example, you could use
$ drush pml --no-core --status="not installed" --type=module
Package Name Version
Administration Actions permissions (VBO) (actions_permissions) 7.x-3.2
BackgroundField BackgroundField (backgroundfield) 7.x-1.5
Chaos tool suite Better Jump Menus (jump_menu) 7.x-1.4
Chaos tool suite Chaos Tools (CTools) AJAX Example (ctools_ajax_sample) 7.x-1.6
***Note and caution:*** Always try this stuff on a development or vagrant box first. NEVER blindly do this to a production box.