hidden attribute on Windows files

R

rbt

How do I enable the hidden attribute when creating files on Windows
computers? I'd *really* prefer to do from the standard Python installer
(no win32 extensions). Any tips?

Thanks
 
R

Roel Schroeven

rbt said:
How do I enable the hidden attribute when creating files on Windows
computers? I'd *really* prefer to do from the standard Python installer
(no win32 extensions). Any tips?

You could do

os.system('attrib +h hidethis.txt')

but that only works if hidethis already exists.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

rbt said:
How do I enable the hidden attribute when creating files on Windows
computers? I'd *really* prefer to do from the standard Python installer
(no win32 extensions). Any tips?

With pure Python and just the standard installer, you need to invoke
attrib.exe, as

attrib.exe +H <pathname>

Use os.system to invoke that command, make sure you get the quoting
right in case pathname might contain spaces. attrib.exe is located
in the system folder (windows\system32), so it should be on the PATH.

HTH,
Martin
 
J

John Machin

rbt said:
How do I enable the hidden attribute when creating files on Windows
computers? I'd *really* prefer to do from the standard Python installer
(no win32 extensions). Any tips?

Thanks

Breaking your problem down a bit:
1. How is that done from the command line in Windows?
2. How to execute an os command line from within stock-standard Python?

Which of those parts are you having trouble with?

If you want to help yourself, DON'T read the end of this message ...







=== Warning: spoon-feeding follows ===

[results of "dir" command are trimmed down to the bare essentials]

C:\junk\hidatt>dir
08/03/2005 07:56a <DIR> .
08/03/2005 07:56a <DIR> ..
08/03/2005 07:56a 13 fubar

C:\junk\hidatt>python
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.08/03/2005 07:56a <DIR> .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,222
Messages
2,571,137
Members
47,754
Latest member
Armand37T7

Latest Threads

Top