I need to get a list of files in a directory, where the filenames have to be unicode.
The following code gives me a list of files.
files = [ f for f in listdir(filedirectory) if isfile(join(filedirectory,f)) ]
for fi in files:
print(fi)
print(type(fi))
Result:
AT10_nachmittags.JPG
<type 'str'>
AT11_nachmittags.JPG
<type 'str'>
AT12_nachmittags.JPG
<type 'str'>
AT2_morgens2.JPG
<type 'str'>
AT3_morgens.JPG
<type 'str'>
AT_morgens.JPG
<type 'str'>
Bühne.JPG
<type 'str'>
Bühnenauftritt.JPG
<type 'str'>
The problem is that these are not unicode. I need them to be unicode so I can write them in a file because they include german "umlaute" unicode symbols.
I'm working on Mac OS X 10.10.4 with python 2.7.6