1

I have been wondering how one could clean up uninstalled modules in the modules folder. Perhaps by piping some drush output to rm rf...

I noticed drush pm list gives small modules that exist in larger enabled modules. Any tips?

drush pm-list --type=Module --no-core --status="Not installed"

2 Answers 2

2

Drush is a tool for performing Drupal operations in the shell. If you've already uninstalled the module then there's nothing left in Drush's purview to do, just perform a rm on each module you need removed. pm-list has --pipe option that will spit out the module short name. You can use that output to find the correct directory and remove it. Something like...

drush pm-list --type=Module --pipe --no-core --status="Not installed" | while read -r module; do  find sites/all/modules -type d  -name "$module"; done

The remaining work here is more of question about bash (or your shell of choice) than Drush so I'll leave it to the reader to find his own solution.

It should also be mentioned scripting module folder deletion could be fraught with dangers (e.g. not every module is going to be at the same folder, you shouldn't be deleting submodules, etc.); you're better off manually inspecting a list of uninstalled modules (you shouldn't have that many) and removing them judiciously.

0
1

I found and tested this from here: https://www.drupal.org/node/855058#comment-3230936

rm -r `drush dd foo`

But read the thread about safety

1
  • Please note that this command won't check the status of module.
    – Jimmy Ko
    Jul 21, 2016 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.