python read config file and then delete files

python script reading config file and then zipping files after X days from directories. dir contains dynamic files. i have specified the extension and the "startswith" in the config. problem i have is it zips up everything. (if i can get this work will add a delete too). i also want it to perform these actions only when it is in the specified server environment. eg if it is in vod just do vod stuff and skip vod2 as defined in the config file.

This is the errant code. If it finds any file that fulfills the requirements, the whole path is zipped (and is re_zipped multiple times if more than one file is found). Perhaps you want to append the file name to a list, and zip those files only. You could also copy the files to a temporary directory, zip that directory, and then delete everything in it. That may cause problems when un-zipping as it will unzip to the temporary directory and not the original directory.