Q:

Deletion of Read only files on a windows machine running a python script

I have some files on a windows machine(directory d:/test/temp/). For some of the files i have read only permission. For the deletion of the files/folder in the above directory I use a python scripts which recursively iterates over the directory and deletes every file in it.
Following is the snippet of code used for the deletion:  
for entry in  listdir(dest_folder):  
    if isfile(join(dest_folder,entry)) and  basename(filename) != entry:  
       remove(join(dest_folder,entry))

I use a user named: tectt which has all permissions to delete the file.
When I logged into the windows machine with that user I was able to delete the read only files manually. But when I try to delete the read only files through python scripts, I was unable to delete the files.  
An error was thrown saying: [Error 5] Access is denied
I'm new to python scripting. Can some please help me out:
1. To delete these read only files with scripts?
2. Am i missing any things, if so, what would have been them?
Regards,
Vijay

A:

The solution is stated here. Just try to use the search function.
import os, stat
os.chmod(path, stat.S_IWRITE)
os.unlink(path)

How to remove read-only attrib directory with Python in Windows?

