En Tue, 24 Feb 2009 05:15:33 -0200, venu madhav <venutaurus...@gmail.com>
escribió:
> def findFile(dir_path):
> for name in os.listdir(dir_path):
> full_path = os.path.join(dir_path, name)
> print full_path
> if os.path.isdir(full_path):
> findFile(full_path)
> else:
> v = unicode(full_path,errors='skip')
> i = win32api.GetFileAttributes(v)
>
> findFile("F:\\DataSet\\Unicode")
> ---------------------------------------------------------------
> Now when I run this scirpt, the full_path variable which should
contain
the
> name of the file has "????" for non english ( I tried Arabic)
characters.
As
> a result the getfileattributes function is failing to recognise that
file
> and is raising an exception.
> i = win32api.GetFileAttributes(v)
> error: (123, 'GetFileAttributes', 'The filename, directory name, or
volume
> label syntax is incorrect.')
If you call os.listdir with an unicode directory, it returns unicode file
names.
That is (after correcting the previous error in findFile), call it using:
findFile(u"F:\\DataSet\\Unicode")
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list