Created
September 28, 2011 07:26
-
-
Save Amitesh/1247229 to your computer and use it in GitHub Desktop.
unzip folder in ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'zip/zip' | |
def unzip_file (file, destination) | |
Zip::ZipFile.open(file) { |zip_file| | |
zip_file.each { |f| | |
f_path=File.join(destination, f.name) | |
FileUtils.mkdir_p(File.dirname(f_path)) | |
zip_file.extract(f, f_path) unless File.exist?(f_path) | |
} | |
} | |
end |
Thank you greatly. I hate the this ruby ZIP library with a passion. Why is there not Zip::ZipFile.extract that just works? :-(
Awesome thanks
This is awesome. Thank you!
Elegant!
used cd and then mkdir if doesn't exist not mkdir_p but this works too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks