ruby - rails rubyzip make a copy of multiple zip files inside a new zipfile -


So basically I am creating a bunch of zip files that include PvE and PJE. Files are

The following code generates a bunch of zip files which is named as orgname_org_member_orguser1.zip, containing 2 files (a pws and pwe)

  @ successful_ orgs .each do | Org | File = "# {RAILS_ROOT} / My data / # {org [: location]} _ # {org [: member]} _ # {org [: username}} .zip" generated_file (ups_file, organization) File_file (file, organization) zipfile = zip :: zip file.pan (file, zip :: zipfile :: create) pv_text, pws_text = MyGenerator.password pwe_file = "# {RAILS_ROOT} / tmp / # {org [: location]} _ # {Org [: member]} .pwe "pws_file =" # {RAILS_ROOT} / tmp / # {org [: location}} _ # {org [: member]} .pws "file.open (pwe_file, 'w ') {| File | File.write (pwe_text)} File.open (pws_file, 'w') {| File | File.write (pws_text)} zipfile.add ("# {org [: location]} _ # {org [: member]} .pwe", pwe_file) zipfile.add ("# {org [: location]} _ # {Org [: Member]}. Pws ", pws_file) file zipfile.close. Delete the file (pwe_file) .delete (pws_file)  

I want to give the code to what I want to do (to create zip files and store the specified path)

But in addition to the above, all of me. I would also like to create another zip file with the name of the zip, which will include all the zip files created above.

Meaning, all.zip => file1.zip, file2.zip etc

I'm not sure how to adopt that argument in the above code. I appreciate any help Will.

Edit: I do not want to search and add all the files in the directory. I want to add only the zip files created during the above code.

You can collect all the zip files in an array and then add them to a new zip file. Give:

  zip_files = [] @ successful_ orgs.each do | Org | File = "# {RAILS_ROOT} / My data / # {org [: location]} _ # {org [: member]} _ # {org [: username]} .zip" zip_files " & Lt; File gener_file (file, organization) end all_zipped = zip :: zip file.penn ("# {RAILS_ROOT} /tmp/all.zip", ZIP :: ZIPfile :: create) zip_files.each do | F | All_zipped.add (zip_file) expiration  

Note that you are not receiving any additional compression by doing this.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -