Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrap zip files in a folder

Tags:

bash

zip

When zipping a bunch of files, is there a way to wrap them in a folder in the process?

zip -r archive.zip \
    file1.txt \
    file2.txt \
    things/*/*.txt

I'd like the zip to contain a folder that contains the file1.txt, file2.txt and things folder.

Is there a way to do it with zip without having to copy all these files to a folder and then zipping the folder instead?

like image 382
user1340531 Avatar asked Sep 03 '25 15:09

user1340531


1 Answers

Have a trick for you to make this work using a soft link.

  1. cd to a directory that does not hold your files
  2. create a soft link to the folder that holds your files ln -s /folderWithMyStuff containingFolder
  3. zip the soft link zip -r archive.zip containingFolder

Your files will now be saved in archive.zip under a folder called containingFolder

like image 149
AlphaBeta Avatar answered Sep 05 '25 04:09

AlphaBeta