0

Occasionally I need to make files in certain folder using python. To minimize the clutter which such files might cause I would like to make them hidden. It's pretty easy to do this using windows explorer but I have to do it manually for every file which my script creates. Is there any way to specify in python that a certain file which was created should be hidden/invisible in windows explorer?
thanks

5
Contributors
8
Replies
12
Views
8 Years
Discussion Span
Last Post by mahela007
0
fn = 'c:\\file.txt'
p = os.popen('attrib +h ' + fn)
t = p.read()
p.close()
0

could you please explain that bit of code? I'm a newbie programmer so I'm not very good at interpreting code

0

attrib is commandline way to change file attributes (like dos command). On a DOS command window do, "help attrib" to see the options.

0

from the title, it kind of sounds like you're hiding something on your computer from the cops. basically the code opens the document you type in, changes it to become hidden then closes it.

0

os.popen allows you to execute a system call from within Python, as if you were in the command line. Note that this method would only work on Windows platforms...

0

Occasionally I need to make files in certain folder using python. To minimize the clutter which such files might cause I would like to make them hidden. It's pretty easy to do this using windows explorer but I have to do it manually for every file which my script creates. Is there any way to specify in python that a certain file which was created should be hidden/invisible in windows explorer?
thanks

There's a good blog about it + code examples for that at:

http://chaptersinwebsecurity.blogspot.com/2009/02/hiding-files-in-windows.html

http://chaptersinwebsecurity.blogspot.com/2009/04/python-and-alternate-data-streams.html

You may download the source Python fo hide.py / unhide.py at:
http://www.sn3akers.com/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.