Obtaining the attributes and properties of a folder recursively.

Tim Golden mail at timgolden.me.uk
Fri Mar 20 09:58:00 EDT 2009


venutaurus539 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.

TJG



More information about the Python-list mailing list