Skip to content

A Python script to traverse a directory tree and ZIP all files with a given extension

Back in my days of heavy data generation I ran into issues keeping hard drive use under control. Manually making giant ZIP files of entire trees was not a good solution; the files would be huge and extracting small portions became too slow—not to mention the fact that some of the more popular compression programs out there could generate ZIP files that were too large to open (and thus the data was unrecoverable).

So I wrote this script to traverse a tree and create ZIP files of each extension separately. The script is executed with the first argument being the root directory (full path recommended) enclosed in quotes with the trailing slash omitted.

Compression is courtesy of 7-Zip. I guess I should mention I wrote this for Windows and it will require modification for use elsewhere.


Post a Comment

Your email is never published nor shared. Required fields are marked *