44

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?

0

1 Answer 1

61

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/*
4
  • Thanx, done the same with winrar
    – Omu
    Nov 21, 2015 at 10:11
  • 1
    About -r, 7z manual says "Recurse subdirectories (CAUTION: this flag does not do what you think, avoid using it)" Dec 1, 2017 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, 2019 at 14:14
  • 2
    7z a myzip ./MyFolder/* syntax works brilliantly. But it is an absurd syntax, I must say.
    – pgr
    Jun 5, 2020 at 11:54

Not the answer you're looking for? Browse other questions tagged .