I want to create a ZIP archive of a directory without going into the directory itself, and not include that directory
Zip the contents of a folder without including the folder itself - This post guides to changed the current directory and then create the archive. But, as stated earlier, i do not want to change the current directory.
This is the structure of the directory that I want to archive
parentdir/
parentdir/dir1/
parentdir/dir1/file1.txt
parentdir/dir1/file2.txt
parentdir/dir2/
parentdir/dir2/file1.txt
parentdir/dir2/file2.txt
And the desired archive would contain
dir1/
dir1/file1.txt
dir1/file2.txt
dir2/
dir2/file1.txt
dir2/file2.txt
If I use the command
zip -r output.zip parentdir/
this includes the parentdir
as well in the archive.
Is there any flag that allows us to create an archive without the parentdir
? I do not want to change the current directory to the parentdir
. I cannot also use the -j
flag,since I do not want to junk the rest of the paths. Can i accomplish this from any directory?