Deleting Directories

Rico Huijbers E.A.M.Huijbers at REMOVEstudent.tue.nl
Fri May 21 11:21:31 EDT 2004


Laura McCord wrote:
> This is probably a very basic question but I started learning python. I
> am almost done writing my delete directory script but I am at a stand
> still right now. 
> I want to delete folders in my "/var/www/html/da" directory that are
> over 1 day old.
> 
> But, when I find the folder a simple rmdir() command does not work
> because the directory is not empty. What else do I need to do to delete
> a directory that contains content?

Assuming you already figured out how to check the directories' 
timestamps, shutil.rmtree() will do what you want.



More information about the Python-list mailing list