Reputation: 157
I am trying to create a new dictionary.
import os
import datetime
parent_dir = "E:\\"
directory = "cali"
now = datetime.datetime.utcnow().strftime("%b-%d_%H:%M:%S")
path = os.path.join(parent_dir, directory, now)
os.makedirs(path)
But I am getting this error:
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\cali\\Dec-25_07:53:44'
Upvotes: 1
Views: 3543
Reputation: 686
:
is one of the characters that are illegal for naming directories in Windows.
Therefore, you need to replace :
in ("%b-%d_%H:%M:%S")
with _
to resolve the error.
Upvotes: 2
Reputation: 4872
you cannot create a folder with :
in name , instead replace
now = datetime.datetime.utcnow().strftime("%b-%d_%H_%M_%S")
Upvotes: 2