Skip to content

Instantly share code, notes, and snippets.

@jkubacki
Last active August 29, 2015 14:06
Show Gist options
  • Save jkubacki/a6768d71466277c2b5d1 to your computer and use it in GitHub Desktop.
Save jkubacki/a6768d71466277c2b5d1 to your computer and use it in GitHub Desktop.
Replace files in catalog tree from another catalog. Without fileutils and with binary flags for microsoft, fuckin, windows.
catalog_search = 'test'
catalog_copy_from = 'test2'
Dir.glob("#{catalog_search}/**/*").each do |name_target|
next if File.directory? name_target
name_main = "#{catalog_copy_from}/#{File.basename name_target}"
if File.file? name_main
content = File.open(name_main, 'rb') {|file| file.read }
File.open(name_target, 'wb') {|file| file.write(content) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment