use File::Find; finddepth sub {(!-d or /^.{1,2}$/);rmdir($_); warn $File::Find::name,$! if $! =~ /not empty/},@ARGV;