Skip to content

Instantly share code, notes, and snippets.

@kodavn
Forked from keithweaver/create-folder.py
Created August 22, 2021 06:51
Show Gist options
  • Save kodavn/3c8b40b8300e0296b86eda856789a639 to your computer and use it in GitHub Desktop.
Save kodavn/3c8b40b8300e0296b86eda856789a639 to your computer and use it in GitHub Desktop.
Create a folder with Python
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
# Example
createFolder('./data/')
# Creates a folder in the current directory called data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment