chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Hide folder with Python filter_list
Author
Message
Hide folder with Python #1
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.

Reply

RE: Hide folder with Python #2
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.
[Image: AD83g1A.png]

[+] 1 user Likes mothered's post
Reply

RE: Hide folder with Python #3
Provide System Attrib To The Folder You Want to Hide.
Even In The above Program He Has Set The File Attrib To System Attrib And Hidden It.

Instead Of Using win32api And Coding That Long Program...
call the command Through CMD using Built-In OS Library In Python

Thats It .
(This post was last modified: 09-05-2019, 05:46 PM by sefefew.)
I Am InEvitable

Reply

RE: Hide folder with Python #4
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")

Reply

RE: Hide folder with Python #5
(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
I Am InEvitable

Reply






Users browsing this thread: 1 Guest(s)