Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby delete folder recursively

require 'fileutils'
target_folder = 'some_path/delete_me'

FileUtils.rm_rf(target_folder)

# if you want to keep target_folder, but delete all folders underneath.
FileUtils.rm_rf(Dir.glob("#{target_folder}/*"))

# if you want to only delete empty folders recursively.
Dir.glob("#{target_root_path}/**/")
  .reverse_each { |d| Dir.rmdir d if Dir.entries(d).size == 2 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #delete #folder #recursively
ADD COMMENT
Topic
Name
7+6 =