Obtaining the attributes and properties of a folder recursively.

venutaurus539 at gmail.com venutaurus539 at gmail.com
Sat Mar 21 04:27:39 CET 2009

On Mar 20, 6:58 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> venutaurus... at gmail.com wrote:
> > Thank you for your suggestion but.. I'll have around 1000 such files
> > in the whole directory and it becomes hard to manage such output
> > because again I've to take this snapshot before backing up the data
> > and have to do the same and compare both when the data gets restored,
> > just to verify whether the restore happened successfully or not.
> The .dump is simply a way of seeing quickly what the data is.
> If you want to store is somewhere (.csv or whatever), you can
> just select the attributes you want. Note, though, that ACLs
> are tricky to compare. Something like the following might do
> what you want, perhaps?
> <code>
> import os
> import csv
> from winsys import fs
> with open ("info.csv", "wb") as f:
>   writer = csv.writer (f)
>   for f in fs.flat ("c:/temp/cabsdk"):
>     print f
>     writer.writerow ([
>       f,
>       f.created_at,
>       f.written_at,
>       f.attributes,
>       f.security (),
>       f.size
>     ])
> os.startfile ("info.csv")
> </code>
> This uses the security's SDDL representation, which while
> opaque does at least give you a before-and-after check.

Thank you Sir for your reply. It is working for me. But is failing if
I have Unicode characters in my path. I tried giving a 'u' in front of
the path but still it fails at f.createdat. Does it support Unicode

This the traceback which I got while running the above python script
on my data:
\\?\C:\JPDump\AGIT_FSDM\Unicode\Arabic files\Arabicְדזךמאּשּׁתּ
Traceback (most recent call last):
  File "C:\MFDump\snapshot.py", line 10, in <module>
  File "C:\Python26\Lib\site-packages\winsys\fs.py", line 476, in
    return utils.from_pytime (wrapped (win32file.GetFileAttributesEx,
  File "C:\Python26\Lib\site-packages\winsys\exceptions.py", line 26,
in _wrapped
    raise exception (errmsg, errctx, errno)
x_invalid_name: ('The filename, directory name, or volume label syntax
is incorrect.', 'GetFileAttributesEx', 123)


Thank you,
Venu Madhav,

More information about the Python-list mailing list