How can I change file attributes in windows with python?

3

I'm trying to leave a hidden .txt file. How can I do this using python command line?

    
asked by anonymous 17.12.2016 / 17:41

1 answer

3

In windows you can do this:

import ctypes
FILE_ATTRIBUTE_HIDDEN = 0x02

ret = ctypes.windll.kernel32.SetFileAttributesW('CAMINHO/PARA/FICHEIRO.txt',
                                                FILE_ATTRIBUTE_HIDDEN)
if ret:
    print 'Ficheiro definido para oculto'
else:  # se retornar algum erro
    raise ctypes.WinError()

Response removed from here .

I did not test because I do not have windows, so I'm not sure if it will work, if it does not work, it says I'll take the answer from here

    
17.12.2016 / 17:43