Obtaining the attributes and properties of a folder recursively.

Tim Golden mail at timgolden.me.uk
Mon Mar 23 09:43:51 CET 2009

venutaurus539 at gmail.com wrote:
> On Mar 21, 3:05 pm, Tim Golden <m... at timgolden.me.uk> wrote:
>> venutaurus... at gmail.com wrote:
>>> 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
>>> Characters?
>>> This the traceback which I got while running the above python script
>>> on my data:
>>> -----------------------------------
>>> \\?\C:\JPDump\AGIT_FSDM\Unicode\Arabic files\Arabicְדזךמאּשּׁתּ
>>> פּפֿשּﭏכּטּךּאָשּׁבֿפֿװײ״טצתא
>> In fact, to give me something to test against, would you
>> be able to send me the result of running this code, please?
>> It's just listing the names of the files under that particular
>> directly, encoded as utf8 so they'll survive transit:
>> <code>
>> import os
>> from winsys import fs
>> PATH = r"\\?\C:\JPDump\AGIT_FSDM\Unicode\Arabic files"
>> f = open ("arabic-files.txt", "wb")
>> for filename in fs.listdir (PATH):
>>   f.write (filename.encode ("utf8") + "\r\n")
>> f.close ()
>> os.startfile ("arabic-files.txt")
>> </code>
>> Thanks
>> TJG
> This is the output for your code Sir. But I think os.stat is
> sufficient to satisfy all my requirements. May be we just have to make
> the path itself a Unicode path.
> Arabicְדזךמאּשּׁתּפּפֿשּﭏכּטּךּאָשּׁבֿפֿװײ״טצתא
> Arabicְדזךמאּשּׁתּפּפֿשּﭏכּטּךּאָשּׁבֿפֿװײ״טצתא.doc
> Arabicְדזךמאּשּׁתּפּפֿשּﭏכּטּךּאָשּׁבֿפֿװײ״טצתאnew.doc
> الأبجدي.txt
> تعلم اللغة الإيطالية مجان.doc
> دروس مجانية في اللغة الإنجليزي.txt
> دروس مجانية في اللغة الإنجليزي1.txt

Yes, thanks to your question I discovered one or two small
bugs in the WinSys unicode handling, hopefully now fixed.
But, I agree, you can use os.stat to do pretty much all
you want by passing unicode filenames. You'll also need
to use the win32security functions to get the ACL stuff.


More information about the Python-list mailing list