# Create a folder save a file in that and zip the folder

**URL:** <https://www.ruby-forum.com/t/create-a-folder-save-a-file-in-that-and-zip-the-folder/125319>\
**Category:** Deployment\
**Created:** [January 8, 2008, 6:33am UTC](https://www.ruby-forum.com/t/create-a-folder-save-a-file-in-that-and-zip-the-folder/125319 "2008-01-08T06:33:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [January 8, 2008, 6:33am UTC](https://www.ruby-forum.com/t/create-a-folder-save-a-file-in-that-and-zip-the-folder/125319/1 "2008-01-08T06:33:49Z")

</div>

hi,  
can anyone help me.

I want to create a folder, create another file of .url type and save the  
.url file in the folder and zip the folder. I am sending the code which  
I have written.

dir\_name = Dir.new(“InstitutionShortcut”)  
file\_path =  
“#{RAILS\_ROOT}/public/test/#{dir\_name}/Isabel-#{@institutions.institution\_name}.url”  
f = File.new(file\_path, “w”)  
content = “”  
content += “[InternetShortcut]\n”  
content += “URL=http://192.168.1.233:5555/index.jsp?”  
content += “passcode=“removed\_email\_address@domain.invalid+”\n”  
content += “IconFile=http://192.168.1.233:5555/favicon.ico\n”  
content += “IconIndex=1\n”  
content += “Modified=30B027EB835EC40198”  
f.write( content )  
f.close  
dir\_name.zip

can anyone help me

Thanks in advance

---

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [January 8, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/create-a-folder-save-a-file-in-that-and-zip-the-folder/125319/2 "2008-01-08T16:36:04Z")

</div>

What was your problem?

On Jan 8, 2008 1:33 PM, Raju A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “#{RAILS\_ROOT}/public/test/#{dir\_name}/Isabel-#{@institutions.institution\_name}.url”  
> dir\_name.zip
> 
> can anyone help me
> 
> ## Thanks in advance
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Jeff X.  
Software Journeyman - [http://gigix.thoughtworkers.org](http://gigix.thoughtworkers.org)  
Open Source Contributor - [http://stomperl.googlecode.com/](http://stomperl.googlecode.com/)  
Technical Evangelist - [InfoQ - 促进软件开发及相关领域知识与创新的传播-极客邦](http://www.infoq.com/cn/)

---

<div class="post-metadata">

**Author:** ![raju\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a9adbd/32.png) [@raju\_k](https://www.ruby-forum.com/u/raju_k)\
**Post date:** [January 8, 2008, 7:32pm UTC](https://www.ruby-forum.com/t/create-a-folder-save-a-file-in-that-and-zip-the-folder/125319/3 "2008-01-08T19:32:56Z")

</div>

On Jan 8, 7:33 am, Raju A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> hi,  
> can anyone help me.
> 
> I want to create a folder, create another file of .url type and save the  
> .url file in the folder and zip the folder. I am sending the code which  
> I have written.
> 
> dir\_name = Dir.new(“InstitutionShortcut”)

This will NOT create a directory. use dir.mkdir(…) for that.

> ```
> f.write( content )
> f.close
> dir_name.zip
> 
> ```

This will NOT zip your dir :). .zip is Enumerable method:  
[http://ruby-doc.org/core/classes/Enumerable.html#M003169](http://ruby-doc.org/core/classes/Enumerable.html#M003169)

To make zip archives check the ‘rubyzip’ gem.
