Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a file hidden on Windows?

On windows you can right-click a file, click on properties and select hidden. How can I do this to a file in python?

like image 721
Jared Parker Avatar asked Apr 16 '17 20:04

Jared Parker


People also ask

How do I make a file invisible on my desktop?

Right-click on the folder to go to the folder's Properties. When the Properties window opens, go to the Customize tab. In the Folder Icon section click on the change icon button. In the icon window that shows up, make sure to click on the invisible icon and click on Accept.

Can you hide files on your PC?

How to Hide Folders or Files in Windows 10 with File Explorer. Before you can hide folders or files, you need to right-click the item in question and select “Properties”. In the “General” tab of your file or folder properties, look for the “Hidden” check box and tick it. If you hide a file, that's all you need to do.


1 Answers

If you don't want/don't have access to win32 modules you can still call attrib:

import subprocess
subprocess.check_call(["attrib","+H","myfile.txt"])
like image 165
Jean-François Fabre Avatar answered Oct 01 '22 21:10

Jean-François Fabre