Sinisterly
Hide folder with Python - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Hide folder with Python (/Thread-Hide-folder-with-Python)



Hide folder with Python - trixxx_128 - 05-10-2019

Hi Hi,
i am looking for variants how to hide folders with python..
I've already worked out a solution.

Code:
import shutil import os import win32con import win32api path1=r"C:\Users\user1\Desktop\5" path2=r"C:\Users\Administrator\Dokumente\Word" #path3=r"C:\Windows\System32\Test" path_exist=os.path.exists(path2) if path_exist==True:    print("Ok") else:    shutil.copytree(path1,path2)    print("copy from ", path1)    print("copy to: ",path2) win32api.SetFileAttributes(path2,win32con.FILE_ATTRIBUTE_HIDDEN) #Verstekct den Ordner print("hiden")

Does someone know other possibilities to hiden folders with python?
It is possible to create a folder in the system32 windows folder (see path3  to bypass this error PermissionError: [WinError 5] Access is denied)

I'm sorry for my bad english.


RE: Hide folder with Python - mothered - 05-10-2019

Quote:It is possible to create a folder in the system32 windows folder (see path3 to bypass this error PermissionError: [WinError 5] Access is denied)

The directory Is In use by the OS, hence the permission error.

Boot with a Live CD, navigate to the System32 directory and perform your tasks thereafter.


RE: Hide folder with Python - sad_satan - 09-11-2019

in my case when i want to hide files or folders using the shell i use the bat command attrib, that allow the user to set attributes for a specific file, you ask how could you do it in python, just try to do it using the system enviroment, if you need it to work in linux and windows include an if condition for each case.
try this code to use the operative system enviroment.
import os
os.system("attrib +h " + "your file name")


RE: Hide folder with Python - sad_satan - 12-21-2019

(09-12-2019, 06:13 AM)sefefew Wrote:
(09-11-2019, 05:05 PM)sad_satan Wrote: in my case when i want to hide files or folders using the shell i use the bat command attrib, that allow the user to set attributes for a specific file, you ask how could you do it in python, just try to do it using the system enviroment, if you need it to work in linux and windows include an if condition for each case.
try this code to use the operative system enviroment.
import os
os.system("attrib +h " + "your file name")


If U Do Not Apply System Attrib...
Then The File Will Be Visible If The User Clicks On View Hidden Files
you are so ...