def prune_empty_directories(path)
      all_files = all_files(path)

      directories = all_files.select { |x| File.directory?(x) }
      directories.sort! { |a, b| b.size <=> a.size }

      directories.each do |directory|
        entries = all_files(directory)
        FileUtils.rmdir(directory) if entries.empty?
      end
    end
def prune_empty_directories(path)
      all_files = all_files(path)

      directories = all_files.select { |x| File.directory?(x) }
      directories.sort! { |a, b| b.size <=> a.size }

      directories.each do |directory|
        entries = all_files(directory)
        FileUtils.rmdir(directory) if entries.empty?
      end
    end
OK, HERES THE PLAN...

 1. Get all the directories in the entire file tree.
 2. Sort them by the length of their absolute path.
 3. Go through the list, longest paths first, and remove
    the directories that are empty.

 This ensures that directories containing empty directories
 are also pruned.