I'm trying to create a folder that is valid according to the lib os
in Windows.
# Replace <user>
filePath = r"C:\Users\<user>\AppData\Local\Temp\aux")
if not os.path.exists(filePath) and os.access(os.path.dirname(filePath), os.W_OK):
os.makedirs(filePath)
But it failes with the following error
Traceback (most recent call last):
File "C:\Users\<user>\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-a7b7e2731f40>", line 1, in <module>
os.makedirs(filePath)
File "C:\Users\<user>\Anaconda3\lib\os.py", line 221, in makedirs
mkdir(name, mode)
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\Users\<user>\AppData\Local\Temp\aux'
The problem? You can't use "aux" as a folder name in Windows.
Is there a workaround in python to:
- "Really" check if the folder is valid (the "if" in the code above is not enough)
- Create the folder anyway?