#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Compression into zip (without source root dir)


    Hello,

    I have a directory structure like this below:

    src(dir)
    ..chrome(dir)
    ..install.rdf
    ..chrome.manifest

    how can I compress them into zip where the content should be the following:
    ..chrome(dir)
    ..install.rdf
    ..chrome.manifest

    command 'zip -ur foo.zip ./src' will put the src into archive.

    Is there any other well configurable archiver which knows the zip ?
    Or the zip can omit the source root dir ?

    Thanks in advance.

    Cs.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    I don't think zip is the one that lets you go relative to a specific directory (tar maybe?) as opposed to the current directory, so
    Code:
    cd src; zip -ur ../foo.zip *; cd ..
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42
    Try it like this:
    Code:
    zip -ur foo.zip src

    Clip from 'zip' man page:
    Code:
    -r     Travel the directory structure recursively; for example:
    
                  zip -r foo foo
    
           In this case, all the files and directories in foo are saved  in
           a zip archive named foo.zip, including files with names starting
           with ".", since the recursion does not use the shell's file-name
           substitution  mechanism.  If you wish to include only a specific
           subset of the files in directory foo and its subdirectories, use
           the  -i  option  to specify the pattern of files to be included.
           You should not use -r with the name  ".*",  since  that  matches
           ".."   which will attempt to zip up the parent directory (proba-
           bly not what was intended).
    
    -R     Travel the directory structure recursively starting at the  cur-
           rent directory; for example:
    
                  zip -R foo '*.c'
    
           In this case, all the files matching *.c in the tree starting at
           the current directory  are  stored  into  a  zip  archive  named
           foo.zip.  Note for PKZIP users: the equivalent command is
    
                  pkzip -rP foo *.c

IMN logo majestic logo threadwatch logo seochat tools logo