I am looking for a way to create new folders within multiple existing folders. For example I have folders a,b,c.. etc and I want to create a new folder inside each of these existing folders and name the new folders a1,b1,c1,.. etc. using a python script.
-
1What did you try that didn't work?Wooble– Wooble2013-01-24 17:11:31 +00:00Commented Jan 24, 2013 at 17:11
-
I've tried this <<< import os root_path = '/my/root/path/' folders = ['a1','b1','c1'] for folder in folders: os.mkdir(os.path.join(root_path,folder))user1549676– user15496762013-01-24 17:40:33 +00:00Commented Jan 24, 2013 at 17:40
-
I forgot to say that what i did above did nothing at all. Sorry about the formating. Am still trying to figure it out. I can't find any tips in the faqs for the life of me...:(user1549676– user15496762013-01-24 17:48:25 +00:00Commented Jan 24, 2013 at 17:48
Add a comment
|
1 Answer
Try looping through your list of folders rather than passing in the list. It is not the cleanest method out there but you can do something like:
parents = [p1, p2, p3]
childern = [c1, c2, c3]
for p in parents:
for c in children:
os.mkdir(os.path.join(p,c))
1 Comment
JonathanV
That I did. I am going to go ahead and blame someone else for my mistake.