By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,532 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,532 IT Pros & Developers. It's quick & easy.

Needing to create a program that will search my hard drive for certain folders

P: 3
I am new to programming in Python, but I am very excited about the possibilities that it (Python) has.

I maybe jumping the gun a little bit here, but this is what I would like to do:
************************************************** ******************************************

I would like to create an executable program that when ran it will search my hard drive for certain folders that contain different files. Once the program finds these folders, I would like the program to zip each of the folders up and then e-mail each of the folders to a certain e-mail address.

************************************************** ******************************************
Is this possible??? I have been told by someone else that it is…I just want to make sure.

If this is possible…How would I do this (please remember that I am new to Programming in Python).

Thanks for all of the help.

Jul 11 '06 #1
Share this Question
Share on Google+
1 Reply

P: 2
It's very possible.

I won't write out a full program, but here's a basic outline.

First, you'll need to import os to help you with all the path and directory stuff.

Next, you'll want to call os.walk on a directory, this will allow you to (recursively) get the name of each file/folder and process the ones you want, e.g., adding them to a list.

So let's suppose you've ran os.walk, and you now have a list with the folder's you want to zip. To zip these folders files, checkout the zipfile Module.

Basically you'll have to create a ZipFile object for each folder in your list, then loop through each file in these folders adding them to the zip (ZipFile.write)... you might have to use os.walk for that too.

Good luck! :cool:
Jul 12 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.