I am looking for a python version 2.6.6 script that logs into a gmail account and down loads attachments. The script must be able to sort attachments based on their file extension and place them into directories accordingly. An example would be any image extension goes into an image directory, any movie extension goes into a different directory. My main goal for this script is to download images, movies, and text files from the Gmail account. I have already found a script that almost does what I want it to do but it does not do some critical functionalities that I would like to have. For example, if I have two images named Photo.jpg in different e-mails, only the last file named Photo.jpg is shown. I think that the second file overwrites the first file. I cannot have this happen, I would like to have both photos downloaded at the same time, but different file names (Photo-00001.jpg and Photo-00002.jpg) The same goes for movie files.