Recursively Copy Directory And Contents With Ruby
Posted by Weston Ganger
I was writing a script and wanted to copy a directory and all its folders and contents.
Thankfully its ruby so its a very simple solution
# if your not using Rails require fileutils require 'fileutils' FileUtils.cp_r "path/to/my_source_folder/.", "path/to/my_destination_folder"
Dont get tricked, Notice the
. in the source location, you would expect that to be a
* but it doesn’t work like that.
verbose: true to the method if you want to see whats going on.
Related External Links: