Bhavesh Mangal
Bhavesh Mangal

Reputation: 11

Why is the os.path.join() in directory giving an invalid directory name error?

Here it should create the folder naming Model 1 at time but it giving an error message.

# Folder for tensorboard
folder_name = f'Model 1 at {strftime("%H:%M")}'
directory = os.path.join('tensorboard_mnist_digit_logs', folder_name)
try:
    os.makedirs(directory)
except OSError as exception:
    print(exception.strerror)
else:
    print('Successfully created directories!')

Upvotes: 0

Views: 373

Answers (1)

Martin Stagl
Martin Stagl

Reputation: 56

you can not have ':' in a folder name.

Change strftime("%H:%M") to strftime("%H-%M") and it will work

Upvotes: 2

Related Questions