Reputation: 740
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?
Upvotes: 4
Views: 883
Reputation: 740
I ended up unzipping the zip to a folder and then zipping that folder.
zip -r archive.zip \
file1.txt \
file2.txt \
things/*/*.txt
unzip archive.zip -d archive
rm archive.zip
zip -r archive.zip archive
rm -rf ./archive
Upvotes: 1
Reputation: 65
Have a trick for you to make this work using a soft link.
ln -s /folderWithMyStuff containingFolder
zip -r archive.zip containingFolder
Your files will now be saved in archive.zip under a folder called containingFolder
Upvotes: 2