rmdirr

  • description:

    rmdirr recursively removes empty directories.

    rmdirr is written in python, and as such should run on all platforms python supports. Currently however, it has only been tested on linux.

    Distributed under the GPL
  • why?

    After announcing rmdirr on freshmeat, I have received several emails informing me of the similarity of rmdirr to find . -type d -depth | xargs rmdir >& /dev/null or find . -depth -type d -exec rmdir '{}' ';' 2>/dev/null
    • advantages of rmdirr:
      • Verbose mode (you could probably do this by only redirecting stderr to null and then doing a test on the rmdir return code and echoing if there was no error(of course you couldn't use xargs then, or you'd have to limit it to one arg per run). Could also be done with rmdir --verbose and piping to grep to remove the errors, but --verbose is not available on all rmdirs.)
      • Doesn't require running external progs over and over. (not really a problem on real os's or with xargs, but..)
      • Available on all systems python is, no need for find to be installed. (python runs on non-unix os's)
      • Can be imported as a python module and used in other python progs.
      • Works with filenames that contain spaces and other such characters that like to mess up the shell. (find/xargs can handle this with -print0 and -0 args, but these are not available on all versions, and you have to remember to use them.)
      • Even though its harmless, blindly running rmdir on non-empty directories just feels wrong :)
    • advantages of find:
      • Available on all systems find is, no need for python to be installed.
      • Single line solution.
      • Many powerful find(1) options are available.
  • download:

  • links:


ċ
Matthew Mueller,
Jan 16, 2010, 5:26 PM
ċ
rmdirr-1.0.tar.gz
(8k)
Matthew Mueller,
Jan 16, 2010, 5:26 PM
Comments