Skip to content

rmdir recursively while empty? #17

@stuart-little

Description

@stuart-little

This is a suggestion for a possible feature (I found myself having to hand-roll the following recently, and figured it'd make for a good enhancement for File::Directory::Tree).

Suppose you want to remove an empty directory (like rmdir does), and then have that removal bubble up until you encounter a non-empty directory. So:

  • for the path /a/b/c/d, if none of those directories have anything else inside, then running this command would remove all of them;
  • for the same path, if a/b also contains something else apart from c, then running this command on /a/b/c/d would remove c but stop there (because afterwards /a/b wouldn't be empty).
    In short, something like rmtree but only calling rmdir and not empty-directory.

Perhaps whether rmtree calls empty-directory or not can be passed as a named parameter, defaulting to the current version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions