Windows 7, python 2.6.6, 2.7
Create directory 'c:\1\test.'
Try check if it is dir or file, but it is neither:
>>> os.listdir('c:/1')
['test.']
>>> os.path.isdir('c:/1')
True
>>> os.path.exists('c:/1/test.')
False
>>> os.path.isdir('c:/1/test.')
False
>>> os.path.isfile('c:/1/test.')
False
Why directory with . at end not recognized as file system entry at all? But I can obtain it from os.listdir.
As was said in the comments, on Windows, file names that end with a dot, begin/end with spaces, are "aux", etc. etc. etc. - cannot be accessed normally from explorer or from most programming languages.
If you do want to access directories such as "test." from python (or other) code, you can prefix the path with \\?\
, for example:
>>> os.path.isdir(r"\\?\c:\1\test.")
True
Note that ".." and "." will not work as usual when using \\?\
paths - windows will try to access an actual file or directory with that name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With