recursively archiving files
larry.bates at websafe.com
Mon Apr 9 23:45:46 CEST 2007
> Can I use python to recursively compress files under subdirectories
> with a certain format such as "ABC_XXX_XXX.dat" into a .gz or .zip
> file? I used to do it with "tar" on unix, but I don't like to put
> commands into a single line, as it is often more prone to error.
Use os.walk to talk your branch of directories.
Use glob.glob to find only those files that match your mask.
Use zipfile or tarfile module (depending on if you want .gz or
.zip compressed file) to add each file to the compressed file.
More information about the Python-list