Problem in identifying an archived file in Windows

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Feb 25 09:19:19 CET 2009


En Wed, 25 Feb 2009 05:40:22 -0200, venu madhav <venutaurus539 at gmail.com>  
escribió:

>            I am writing an application which has to identify the
> archived files in a given directory.I've tried using the function
> i = win32api.GetFileAttributes (full_path)
>
> to obtain the attributes.But am unable to identify based on the value
> it returns as it is returning 5152, 13856 etc for different files but
> all of them are archived. Is there any way to come to a conclusion
> using these numbers about whether a file is archived or not.

So you're using the pywin32 package. It comes with a help file  
(PyWin32.chm), you can open it right from the menu: Start, All Programs,  
Python XX, Python for Windows documentation.
Go to the GetFileAttributes topic. It says "The return value is a  
combination of the win32con.FILE_ATTRIBUTE_* constants". Ok, which  
constants? Let Python tell us:

py> import win32con
py> [name for name in dir(win32con) if name.startswith("FILE_ATTRIBUTE_")]
['FILE_ATTRIBUTE_ARCHIVE', 'FILE_ATTRIBUTE_ATOMIC_WRITE',  
'FILE_ATTRIBUTE_COMPRESSED', 'FILE_ATTRIBUTE_DIRECTORY',  
'FILE_ATTRIBUTE_HIDDEN', 'FILE_ATTRIBUTE_NORMAL',  
'FILE_ATTRIBUTE_READONLY','FILE_ATTRIBUTE_SYSTEM',  
'FILE_ATTRIBUTE_TEMPORARY', 'FILE_ATTRIBUTE_XACTION_WRITE']

What do they mean? The best source is the Microsoft site. There is a very  
convenient link in the help topic: "Search for GetFileAttributes at msdn,  
google or google groups." Click on msdn, the first result is  
<http://msdn.microsoft.com/en-us/library/aa364944(VS.85).aspx>
You apparently are looking for FILE_ATTRIBUTE_ARCHIVE.

-- 
Gabriel Genellina




More information about the Python-list mailing list