Search
 
SCRIPT & CODE EXAMPLE
 

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 }
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby replace first character in string 
Ruby :: ruby if dates is in range 
Ruby :: rails validators 
Ruby :: ruby intersection of two arrays 
Ruby :: run a specific migration rails 
Ruby :: rails destroy not working 
Ruby :: rails update without validation 
Ruby :: ruby deep merge 
Ruby :: ruby make chain method 
Ruby :: rails reset database 
Ruby :: remove gem rails 
Ruby :: validates inclusion of rails 
Ruby :: ruby rails activerecord to array hash 
Ruby :: ruby remove last element of string 
Ruby :: ruby is character 
Ruby :: text_field_tag rails 
Ruby :: capitalize composed name ruby 
Ruby :: rust overwrite file 
Ruby :: ActionController::InvalidAuthenticityToken rails when submitting form 
Ruby :: create table index unique rails 
Ruby :: sendgrid ruby on rails 
Ruby :: ruby is method defined 
Ruby :: install ruby on rails ubuntu 18.04 
Ruby :: setp in ruby loop 
Ruby :: JSON.parse prevent error ruby 
Ruby :: ruby exit out of loop 
Ruby :: ruby puts object 
Ruby :: ruby sinatra enable sessions 
Ruby :: rails activerecord saved_change_to 
R :: outlier tagging boxplot r 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =