remove read only flag

Lemniscate d_blade8 at hotmail.com
Wed May 1 16:36:13 EDT 2002


Hi,

Lutz in "Programming Python" actually provides a script to do exactly
what you just wanted to do (change the file permissions on something
burned onto a CD).  Yet another reason to invest in the book.  Next,
you are accomplishing your goal, so you may not care.  But you can
just write a script to call an os.system call changing the attributes
that way...

import os
filename = "test.lmn"
os.system('attrib -R %s' % filename)  # H is the Read attribute, goto
'help attrib' for others

You can make a list using something like os.listdir (or os.path.walk)
and do it that way.  This is a very windows oriented method, but you
could add an OS check to make it more portable.  Personally, I shy
away from having windows users use the os.chmod() function as
windows-users are, historically, 1) less prone to understand file
permissions and 2) Windows is going towards an 'NT' platform where you
may not have permissions to chmod(666) or the like.

Lem



"GerritM" <gmuller at worldonline.nl> wrote in message news:<aamrae$a3i$1 at reader1.tiscali.nl>...
> This does not answer your request. I asked myslef the same question about
> half an hour ago, becauase I copies an extensive directory structure from
> CDR to my hard disk, with the nasty side effect that all files are marked as
> read-only. Windows 98 explorer does not seem to provide any easy way to
> switch all the files back to writeable. When thinking about a short Python
> script I thought up the work around (which are needed all the time under
> windows):
> via the search window you can get all the files by searching for *; CTRL-A
> selects all and then via properties youcan change all these files at once.
> So for now I don't need the Python call to reset the read only flag :-)
> 
> regards Gerrit



More information about the Python-list mailing list