i know how to add a file to the root folder within a zip file:
zip -g xxx.apk yyy.txt
but i've no idea how to specify a particular folder within a zip file
After creating a zip file, you can remove a file from the archive using the -d option. 2. -u Option: Updates the file in the zip archive. This option can be used to update the specified list of files or add new files to the existing zip file.
You can either click the Terminal icon in the Apps menu, or press Ctrl + Alt + T at the same time to open the Terminal. Navigate to the directory you want to create a file in. To do so, type cd followed by the path to the directory you want to create a file in and press Enter..
If you need to add the file to the same folder as in the original directory hierarchy, then you just need to add the full path to it:
zip -g xxx.zip folder/file
Otherwise, probably the easiest way to do that is to create the same layout you need in the zip file in a temporary directory.
To elaborate on @Ignacio Vazquez-Abrams answer from a year ago, you can use a lower level library, such as the one that comes with Python:
#!/bin/bash python -c ' import zipfile as zf, sys z=zf.ZipFile(sys.argv[1], "a") z.write(sys.argv[2], sys.argv[3]) z.close() ' myfile.zip source/dir/file.txt dir/in/zip/file.txt
This will open myfile.zip
and add source/dir/file.txt
from the file system as dir/in/zip/file.txt
in the zip file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With