How do I remove/delete a folder that is not empty?

Submitted 4 years, 6 months ago
Ticket #204
Views 321
Language/Framework Python
Priority Low
Status Closed

I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name").

What is the most effective way of removing/deleting a folder/directory that is not empty?

Submitted on Oct 04, 20
add a comment

1 Answer

Verified

import shutil

shutil.rmtree('/folder_name')

If you want the folder to be deleted regardless of whether it contains read-only files, then use

shutil.rmtree('/folder_name', ignore_errors=True)

 

Submitted 4 years, 6 months ago


Latest Blogs