40

Possible Duplicate: Create an archive from a directory without the directory name being added to the archive

I have a folder that I want to zip completely:

MyFolder
       |
       |--- SubFolder1
       |--- SubFolder2
       |--- file1
       |--- file2

I want to zip everyting into myzip.7z, but I don't want 'MyFolder' to be inside the archive:

myzip.7z
       |
       |--- SubFolder1
       |--- SubFolder2
       |--- file1
       |--- file2

instead of

myzip.7z
       |
       |--- MyFolder
                   |
                   |--- SubFolder1
                   |--- SubFolder2
                   |--- file1
                   |--- file2

How do I do that?

alex
  • 401
  • 1
  • 4
  • 3

1 Answers1

56

This is how I did it.

cd MyFolder
7z a -r ../myzip *

This creates the archive (myzip.7z) in the parent of MyFolder rather than in MyFolder directly.

Alternatively (without first changing into MyFolder):

7z a myzip ./MyFolder/*
Ariel
  • 874
  • 5
  • 7
  • Thanx, done the same with winrar – Omu Nov 21 '15 at 10:11
  • 1
    About `-r`, `7z` manual says "Recurse subdirectories (CAUTION: this flag does not do what you think, avoid using it)" – Gregory Pakosz Dec 01 '17 at 16:44
  • @GregoryPakosz looks like it recursively includes all sub directorys... based on this post, seems like thats the expectations, what do you think is the miss use and what should i do to get a folder and all of its subs? – jrich523 May 19 '19 at 14:14
  • 2
    `7z a myzip ./MyFolder/*` syntax works brilliantly. But it is an absurd syntax, I must say. – pgr Jun 05 '20 at 11:54