Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@qdb99581
Copy link

best code I have ever found, thx!

@JeremyMeissner
Copy link

Thank you!

@Hemantphareesh
Copy link

how to create a folder with name in format yyyy-mm-dd from any year to today

@DanialBahrizadeh
Copy link

thank you man ``

@SaberKazemi1992
Copy link

Great! Thanks so much!

@lucasgcruz
Copy link

Thank you, very useful and helped me understand the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment