File Compression Notes

File Compression Notes

Fixing a corrupted zip file

Using zip

If you try to open a zip file and it won’t unzip you can often fix it by rezipping the file (source).

First, try:

zip -F --out

If that doesn’t work try:

zip -FF --out

If you receive an error message like:

zip error: Entry too big to split, read, or write (Poor compression resulted in unexpectedly large entry - try -fz)


  1. Make sure you have at least version 3.0 of zip
  2. Try adding -fz to the command
zip -FF -fz --out

Using p7zip

If none of this works try p7zip, which can be installed using conda.

conda create -n p7zip python=3
conda activate p7zip
conda install -c bioconda p7zip

This version is pretty out of date, but much less out of date than the one in the HiperGator module system. The one in the HiperGator module is too old to solve the problems we’ve seen.

7za x

Note that this will decompress into the current working directory not into ./corrupted/

Increasing compression

There is a tradeoff between how long it takes to compress something and how much smaller gets. When using zip this is controlled by a numeric argument ranging from 1 (faster) to 9 (smaller). So, if you’re archiving large objects try using zip -9.

If you have a bunch of already zipped files you can recompress them using the following bash loop:

for f in *.zip
  mkdir ${f%.*}
  unzip -d ${} $f
  rm $f
  rm ${f%.*}/${f%.*}.csv
  zip -r -9 $f ${}