473,387 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

hidden attribute on Windows files

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
Jul 18 '05 #1
3 8749
rbt wrote:
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.

--
"Codito ergo sum"
Roel Schroeven
Jul 18 '05 #2
rbt wrote:
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
Jul 18 '05 #3

rbt wrote:
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.
import os
r = os.system('attrib +h fubar')
r 0 r = os.system('dir') 08/03/2005 07:56a <DIR> .
08/03/2005 07:56a <DIR> .. r = os.system('attrib -h fubar')
r = os.system('dir') 08/03/2005 07:56a <DIR> .
08/03/2005 07:56a <DIR> ..
08/03/2005 07:56a 13 fubar


Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wurlds_wurst_coder | last post by:
I want to create a directory structure and would like the folder attributes set to hidden. How can I do this and will my program be able to insert and delete files when this attribute is set. ...
4
by: Greg Bell | last post by:
Hi, Can someone tell me where to look to enable me to read "Folder Options" user settings for hidden/system files from within C#/VB.Net/Any other .NET language. I'm pretty sure it must be part...
13
by: Alexandra | last post by:
Hi, I have a hidden system file that I need to read. I am logged in as an administrator. I can not change the file attributes using the windows explorer.
3
by: Christian Blackburn | last post by:
Hi Gang, All I want is to be able to search a file for files matching a certain criteria. However, VB seems heart set on returning hidden folders along with my list of files. I've tried the...
1
by: Lenny G. | last post by:
What's the best way to do cross-platform hidden file detection? I want to do something like weed-out the files that should be 'hidden' from os.listdir() (which would be files that start with '.'...
8
by: pbd22 | last post by:
hi. i have spent the past week (i am afraid) trying to get the below script for uploading files via a hidden iframe to work. i have narrowed down my problem to the possibility that IE doesnt...
5
by: pbd22 | last post by:
hi. i have a hidden iframe for uploading files. when i check the httpfilecollection on the server, it is always zero - the files never make it to the server. i know all the javascript is working...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
5
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a .Net web service that converts the MODCA files to tif or png file format. This web service runs on a 2003 server. This web service first copies the MODCA file to be converted to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.