Python: User Input to create folders
Question:
I am trying to use the following working code and convert it to user input.
rp = ‘folder_path’
list = [‘test’, ‘test2’]
for i in list:
path = os.path.join(rp, i)
os.mkdir(path)
Essentially, this will make a folder named “test” and “test2” in the folder_path.
Is there a way to make the list from user input?
I have tried the following (manipulating it a bunch) with no luck.
rp = ‘folder_path’
list = []
foldName = int(input(“Folder Name? “))
for i in range(0, foldName):
path = os.path.join(rp, list)
os.mkdir(path)
Answers:
import os
root = 'root path'
x = input("Enter names of folders : ") ## test,test3
list = x.split(",") ## specific separator
for i in list:
path = os.path.join(root, i)
os.mkdir(path)
Quick and dirty – try this .. also not sure what the int conversion is about
I am trying to use the following working code and convert it to user input.
rp = ‘folder_path’
list = [‘test’, ‘test2’]
for i in list:
path = os.path.join(rp, i)
os.mkdir(path)
Essentially, this will make a folder named “test” and “test2” in the folder_path.
Is there a way to make the list from user input?
I have tried the following (manipulating it a bunch) with no luck.
rp = ‘folder_path’
list = []
foldName = int(input(“Folder Name? “))
for i in range(0, foldName):
path = os.path.join(rp, list)
os.mkdir(path)
import os
root = 'root path'
x = input("Enter names of folders : ") ## test,test3
list = x.split(",") ## specific separator
for i in list:
path = os.path.join(root, i)
os.mkdir(path)
Quick and dirty – try this .. also not sure what the int conversion is about