windows - How do I delete files and folders in sub-directories but skip delete for certain file names in Ruby? -


i'm looking way delete files in sub-directories no matter depth keep exclusion list of files not delete.

exclude list = [my.file]

given folder structure (folders end /)

one/   my.file   two/     x.x     x.x     xxx/       xx       my.file     xxxx/       xx 

after delete (every file not in exclude list gets deleted, , folder gets deleted if there no children)

one/   my.file   two/     xxx/       my.file 

i've been using far doesn't go below first level

    inside(directory)         fileutils.rm_rf dir.glob('*').reject { |f| whitelist.include?(f) }     end 

filutils remove_dir removes recursively.

require "fileutils" fileutils.remove_dir("the_dir") 

no weakhearted whitelists though - disappears.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -