Skip to content

Instantly share code, notes, and snippets.

@snelson82
Last active October 21, 2022 21:24
Show Gist options
  • Save snelson82/b37bb823a9268eb7258ac85b95999bef to your computer and use it in GitHub Desktop.
Save snelson82/b37bb823a9268eb7258ac85b95999bef to your computer and use it in GitHub Desktop.
Compressing a folder using RubyZip
require 'zip'
archive_directory_path = ''
archive_zip_path = ''
Zip::File.open(archive_zip_path, Zip::File::CREATE) do |zip_file|
Dir[File.join(archive_directory_path, "**", "**")].each do |file|
zip_file.add(file.sub("#{ archive_directory_path}/", ""), file)
end
end
@snelson82
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment