Hi,I need to delete a directory and its sub directories. However all dir's, sub dir;s and files have read only access. How do i do this efficeintly using the os.walk command. I cannot run this command on the dir as it gives me an error due to the read only attribute. Is there any other way to do
Amresh Kulkarni wrote:
Hi,
I need to delete a directory and its sub directories. However all dir's,
sub dir;s and files have read only access. How do i do this efficeintly
using the os.walk command.
I cannot run this command on the dir as it gives me an error due to the
read only
You must change the directory and file permissions before attempting to remove
them;
even if you are using a python script.
Take a look at os.chmod()
-mtw
On Fri, Jun 16, 2006 at 10:26:34AM -0500, Amresh Kulkarni ([EMAIL PROTECTED])
wrote:
Hi,
I need to delete a directory and its sub
Amresh,
I had this problem a few months back. I
approached it backwards. Maybe not the right way to do it. I removed
all the files and directories and thenhad my exception handle the file if
it was read only. The exception handler changes the file from
read-only to not read only and then
John Corry wrote:
Amresh,
I had this problem a few months back. I approached it backwards. Maybe
not the right way to do it. I removed all the files and directories and
then had my exception handle the file if it was read only. The
exception handler changes the file from
Thanks guys,Error handling seems to be a nice idea to approach this problem. i checked Kent's code and it works fine.I was using a more crude method.def removeDir(dirName) : #Remove any read-only permissions on file.
removePermissions(dirName) for name in os.listdir(dirName): file =
I need to delete a directory and its sub directories. However all
dir's, sub
dir;s and files have read only access. How do i do this efficeintly
using
the os.walk command.
You can'ty since the reasoin the files are read-only is to prevent
them
being over-written or deleted! You need to