Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Zip an existing directory?

Reply
Thread Tools

Zip an existing directory?

 
 
Peter Marks
Guest
Posts: n/a
 
      10-29-2007
Hello,

I am trying to zip an existing directory using the following code:

system("zip /Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29")

but get this error:

zip error: Nothing to do!
(/Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29.zip)

I've seen some tutorials for archiving using the rubyzip gem, but they
all involve manually moving files into an archive instead of archiving
an existing directory. I'm assuming rubyzip is overkill for this?

Thanks,

Peter
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      10-30-2007
> I am trying to zip an existing directory using the following code:
>
> system("zip /Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29")
>
> but get this error:
>
> zip error: Nothing to do!
> (/Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29.zip)


How does zip work on the command line? What does zip --help tell you?

You must list some files for it to zip, or at least a wildcard *.

--
Phlip

 
Reply With Quote
 
 
 
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      10-30-2007
Phlip wrote:
>> I am trying to zip an existing directory using the following code:
>>
>> system("zip /Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29")
>>
>> but get this error:
>>
>> zip error: Nothing to do!
>> (/Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29.zip)

>
> How does zip work on the command line? What does zip --help tell you?
>
> You must list some files for it to zip, or at least a wildcard *.
>


At least on Linux / Cygwin, the command to make a zip archive from a
directory is

$ zip archive-file.zip /path/to/archive

The first parameter is the output archive file name and the *second*
parameter is the path you want to archive. So what it's complaining
about is that you didn't give it the output archive file name, just the
path that you wanted to archive.

 
Reply With Quote
 
petertmarks@gmail.com
Guest
Posts: n/a
 
      10-30-2007
Thanks for the help guys. I am developing in osx and will deploy in
ubuntu (this is for a rails app). My original command does not work in
the command line, nor does zip --help on my local machine.

The command you suggested, Ed, gives the following response:

adding: Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29/
(stored 0%)

The archive it produces contains the folders of the intended archive's
path, but not the contents of the "2007-10-29" folder. I need to archive
the contents of that folder. Any other ideas?

Thanks again,

Peter
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      10-30-2007
Peter Marks wrote:
> Thanks for the help guys. I am developing in osx and will deploy in
> ubuntu (this is for a rails app). My original command does not work in
> the command line, nor does zip --help on my local machine.
>
> The command you suggested, Ed, gives the following response:
>
> adding: Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29/
> (stored 0%)
>
> The archive it produces contains the folders of the intended archive's
> path, but not the contents of the "2007-10-29" folder. I need to archive
> the contents of that folder. Any other ideas?
>
> Thanks again,
>
> Peter


zip -r archive.zip
Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29/

I forgot the "-r" (for recursive).

 
Reply With Quote
 
Peter Marks
Guest
Posts: n/a
 
      10-30-2007
> zip -r archive.zip
> Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29/
>
> I forgot the "-r" (for recursive).


Thanks Ed, that archives the contents of "2007-10-29". Do you know if
there is a way to make the new archive only contain the contents of
"2007-10-29" and not the folders of the path leading to it?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      10-30-2007
Peter Marks wrote:
>> zip -r archive.zip
>> Users/petermarks/Desktop/orbus/public/1/daily/2007-10-29/
>>
>> I forgot the "-r" (for recursive).

>
> Thanks Ed, that archives the contents of "2007-10-29". Do you know if
> there is a way to make the new archive only contain the contents of
> "2007-10-29" and not the folders of the path leading to it?


$ cd /Users/petermarks/Desktop/orbus/public/1/daily/
$ zip -r archive.zip 2007-10-29

There's another way, but I don't remember what it is.


 
Reply With Quote
 
Peter Marks
Guest
Posts: n/a
 
      10-30-2007
M. Edward (Ed) Borasky wrote:
> $ cd /Users/petermarks/Desktop/orbus/public/1/daily/
> $ zip -r archive.zip 2007-10-29
>
> There's another way, but I don't remember what it is.


I think I'll digg up that other way in order to write this into a ruby
function. Thanks again for you guidance Ed.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      10-30-2007
Peter Marks wrote:
> M. Edward (Ed) Borasky wrote:
>> $ cd /Users/petermarks/Desktop/orbus/public/1/daily/
>> $ zip -r archive.zip 2007-10-29
>>
>> There's another way, but I don't remember what it is.

>
> I think I'll digg up that other way in order to write this into a ruby
> function. Thanks again for you guidance Ed.

Isn't there a Ruby library that does this without calling the
command-line function?

 
Reply With Quote
 
Peter Marks
Guest
Posts: n/a
 
      10-30-2007
M. Edward (Ed) Borasky wrote:
> Isn't there a Ruby library that does this without calling the
> command-line function?


Apparently there's rubyzip. I haven't really looked into that too much,
but will if I can't get this to work right.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Existing Dll - using Functions from an existing dll Tristin.Colby@gmail.com Ruby 0 02-05-2008 07:38 PM
Possibility to add a zip-file to a new zip-file with "add to zip" (right-click) ?? erikkie@casema.nl Computer Support 4 06-26-2006 12:18 AM
Why no existing Java type to existing XML schema binding support? nrm Java 3 04-10-2006 04:52 PM
ZipFile - How to update an existing zip file Ian Cook Python 0 11-17-2004 11:36 PM
java.util.zip - problem opening some legitimite me zip files Alex Hunsley Java 1 09-16-2004 02:06 PM



Advertisments