Jul-19-2018, 05:35 AM
Hi,
how can i create a bunch of folders in my specified location and create these folders based on a list of folder names to be created
example my cwd is:
c:\xampp\htdocs\site\
my list of folders to be created inside the cwd is:
c:\xampp\htdocs\site\folder1
c:\xampp\htdocs\site\folder2
c:\xampp\htdocs\site\folder3
c:\xampp\htdocs\site\etc
i have tried:
how can i create a bunch of folders in my specified location and create these folders based on a list of folder names to be created
example my cwd is:
c:\xampp\htdocs\site\
my list of folders to be created inside the cwd is:
folderstobecreatedlist = (['folder1', 'folder2', 'folder3', 'etc'])so my desired outcome would be example:
c:\xampp\htdocs\site\folder1
c:\xampp\htdocs\site\folder2
c:\xampp\htdocs\site\folder3
c:\xampp\htdocs\site\etc
i have tried:
import os
currentpath = "c:\xampp\htdocs\site\"
listOfFoldersToCreate = ['folder1', 'folder2', 'folder3', 'etc']
os.mkdir(currentpath, mode=777
os.mkdir(currentpath, mode)
os.mkdir(currentpath, mode, listOfFoldersToCreate
for foldersToCreate in listOfFoldersToCreate:
os.mkdir(path, mode)but as one can tell i have no experience in python and would really like some help please. preferably in a for loop to just iterate over my list of folders to create and make it done