using os.chmod in windows

Douglas Zongker dougz at cs.washington.edu
Thu Jun 20 04:57:01 CEST 2002


Locke <charter-news at portzer0.virtualave.net> wrote:
: I need to change a file to be 'hidden' in windows. [...] So how 
: do I do this?

If you have the win32 extensions that come with ActivePython
[aspn.activestate.com], then you can do:

    import win32api, win32con
    
    def hide_file( fn ):
        x = win32api.GetFileAttributes( fn )
        x |= win32con.FILE_ATTRIBUTE_HIDDEN
        win32api.SetFileAttributes( fn, x )
    
    def unhide_file( fn ):
        x = win32api.GetFileAttributes( fn )
        x &= ~win32con.FILE_ATTRIBUTE_HIDDEN
        win32api.SetFileAttributes( fn, x )

dz



More information about the Python-list mailing list