Deleting Directories

Tim Golden tim.golden at viacom-outdoor.co.uk
Fri May 21 11:00:37 EDT 2004


| 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?

Well, it depends slightly on what you want to happen
when you encounter a directory with stuff in, but the
simplest answer is probably to use the shutil module
and the rmtree function:

<code>
import shutil
shutil.rmtree ("c:/temp/abc1233")
</code>

TJG


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




More information about the Python-list mailing list