Python – Hide Folders/ File with Python

python

Is there any way to hide folders/ files with Python?

I'm working a huge project (a vulnerability scanner). The project creates a lot of files and folders. Therefore the question, is there any way to make a script that hides files and folders?

Best Solution

If you don't want to go to the hassle of using pywin32 you can call SetFileAttributes with ctypes in the standard library.

ctypes.windll.kernel32.SetFileAttributesW(path, 2)

path must be a unicode string type as this is the unicode version of SetFileAttributes. The constant 2 is from this page (FILE_ATTRIBUTE_HIDDEN). I imagine that there's no way to get nice constant names out of ctypes so you'll have to look them up yourself.