Solved

Problems using zip

Posted on 2004-03-29
4
205 Views
Last Modified: 2010-04-20
I'm trying to zip a directory into a zip file (and all sub dirs and files in the that dir)

I can get it to zip fine, but it stores the directory structure BEFORE the root location of the zip.

Example:
zip myfile.zip E:\www\mydir\ziphere

It zips from the E:, not from the ziphere, so when I extract the file I get the root folders... www then mydir then finally ziphere... that doens't work for my needs (moving zip file one machin to the next) how do I suporess the storing of this early dir structure *but maintain the strucutre beyond my root)?

thanks
0
Comment
Question by:happydog234
  • 2
  • 2
4 Comments
 

Author Comment

by:happydog234
ID: 10705813
To clarify, I'm not getting the content of those folders before the ziproot, but I'm getting the simplest dir strucuture,
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10706788
I have not used zip in a while, so I first have to check if there is a command line option to allow this. One option that will definitely work is to first cd to the "ziphere" directory and use something like this:

cd E:\www\mydir\ziphere
zip myfile.zip .

Or, if you want ziphere to be the first element:
cd e:\www\mydir
zip myfile.zip ziphere
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 10706911
Actually, make this
zip -r myfile.zip .
or
zip -r myfile.zip *

If your want all directories below ziphere, you need to specify the -r switch.

After reading the manpage, it does not look like you can ingore part of the path (you can however junk the directory information completey with the -j flag), so doing the cd is your only option.
0
 

Author Comment

by:happydog234
ID: 10707432
Many thanks- it worked!

[Hangs head in shame].  I can't believe I didn't think of changing the directory...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now