Method: ShellHelpers::PathnameExt::Base#rm_empty_dirs

Defined in:
lib/shell_helpers/pathname.rb

#rm_empty_dirs(rm: true) ⇒ Object

remove all empty directories inside self this includes directories which only include empty directories



325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/shell_helpers/pathname.rb', line 325

def rm_empty_dirs(rm:true)
  r=[]
  if directory?
    find(depth:true) do |file|
      if file.directory? and file.children(false).empty?
        r<<file
        file.rmdir if rm
      end
    end
  end
  r
end