10 examples of 'python create folder if not exist' in Python

Every line of 'python create folder if not exist' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
58def check_folder(folder):
59 if not os.path.exists(folder):
60 try:
61 os.makedirs(folder)
62 except OSError as e:
63 if e.errno != errno.EEXIST:
64 raise
65 return True
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

22def create_folder(folder):
23 """ Create folders to retrieve posters and thumbnails
24 """
25 print(folder)
26 if not os.path.exists(folder):
27 os.makedirs(folder)
200def check_folder():
201 if not os.path.exists("data/badges"):
202 os.makedirs("data/badges")
203 if not os.path.exists("data/badges/temp"):
204 os.makedirs("data/badges/temp")
205 if not os.path.exists("data/badges/temp/tempgif"):
206 os.makedirs("data/badges/temp/tempgif")
49def create_folder(path):
50 """
51 Create a folder if not exists
52 :param path: The path
53 """
54 if not folder_exists(path):
55 xbmcvfs.mkdirs(path)
156def check_folders():
157 if not os.path.exists('data/picwelcome/'):
158 os.mkdir('data/picwelcome/')
9def create_dir(name):
10 if not Path.exists(name):
11 Path.mkdir(name)
189def makeFolder(folderName, display_Str) :
190 if not os.path.exists(folderName) :
191 os.makedirs(folderName)
192
193 strToPrint = "..Folder " + display_Str + " created..."
194 print strToPrint
195
196
197 from os import listdir
46def create_folder(path):
47 os.makedirs(path)
48 msg = f"created folder: {path}"
49 print(msg)
33def make(folder):
34 if not os.path.exists(folder):
35 os.makedirs(folder)
21def make_dir_if_not_exists(path):
22 if not os.path.exists(path): os.makedirs(path)

Related snippets