Copy all files and folders except few in Ruby -


i wondering if can use fileutils.cp_r method copy files , directories source target except .tar files. can give me example better understanding?

thanks

sure you'd have implement kind of filter first this:

[8] pry(main)> dir.glob("**/*") => ["bin", "code_of_conduct.md", "gemfile", "gemfile.lock", "hello.tar", "lib", "license.txt", "mygem.gemspec", "rakefile", "readme.md", "spec"] 

that gave files in directory , subsequent directories(thanks ndn tip), let's filter out hello.tar:

files = dir.glob("**/*").reject { |file| file.end_with?(".tar") } 

now can pass array filteutils::cp_r

fileutils.cp_r(files, destination) 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -