Search code examples
pythonzipgoogle-colaboratorydrive

Zip generated files in Colab


How could I zip some files that I generated in google colab?

I have a bunch of PDF files that I generated with my code. I want them to be ziped in one file in order to download that zip file containing everything. There could be hundred of files generated and that is why I do not want to download them one at a time.

Thanks

PD: I don't want to upload those files to my Drive so the solution !zip -r '/content/folder/"NewFileName.zip"' '/content/folder/"OrginalFileName"' is not valid for me


Solution

  • Does this work?

    !touch a.pdf
    !touch b.pdf
    !touch c.pdf
    !zip all.zip *.pdf
    

    enter image description here

    Obviously change the zip command to point to your files in Colab.