razzi.abuissa.net

Razzi's guide to zip

zip is a command line tool for working with zip archives.

basic usage

zip -r folder.zip folder

inner folder convention

I like to always have a toplevel folder in the zipfile, as opposed to putting files directly in the root of the folder.

$ ls folder
folder/

The reason is that if you unzip a zip archive and it has no containing folder within it, its contents will “pollute” your current directory.

In particular, after it’s been unzipped into the current directory, it’s near impossible to figure out what all files belonged to that zipfile and which ones were already in the current directory.

inspecting a zipfile without opening

You can look at the contents of a zipfile with zip -sf. -sf is short for --show-files; it’s not a combination of -s and -f as some other command line tools.

$ zip -sf folder.zip
Archive contains:
  folder/
  folder/folder/
  folder/folder/file.txt
Total 3 entries (0 bytes)

opening a zipfile

Use unzip:

$ unzip demo.zip
Archive:  demo.zip
   creating: demo
  inflating: demo/gradlew.bat
   creating: demo/gradle
   ...

fish shell zipfile helpers

If you’re using the fish shell, I have some helper functions to deal with zipfiles.

I get annoyed when zipfiles don’t have a top level of their own, so I wrote clean-unzip to always create a toplevel directory even if the zipfile itself doesn’t have all its contents in a folder.

unzip-cd unzips a zipfile and changes directory into it in 1 command. It also uses clean-unzip of course! :)

website

https://infozip.sourceforge.net/

source code

https://sourceforge.net/projects/infozip/files/

depends on