0

So I want to hide a file in python.

hide("VerySecretFile.txt")

This method should also work with folders. any idea how i can do it?

Aaseer
  • 117
  • 10
  • 1
    There's already info on this on this site so it's not clear what's special about your case. What platform are you on? If it's on Windows, did you try anything suggested [here](https://stackoverflow.com/questions/549109/hide-folders-file-with-python)? If it's Mac OS or Linux, did you try the suggestions from [here](https://stackoverflow.com/questions/25432139/python-cross-platform-hidden-file)? In Unix-like operating systems, you just need to add a `.` to the beginning of the file or folder name. – Random Davis Nov 23 '21 at 17:13

1 Answers1

0

You can just add +h to file properties like that:

p = os.popen('attrib +h ' + filepath)
t = p.read()
p.close()
Vasily
  • 173
  • 11