-1

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.

3
  • 1
    What did you try that didn't work? Commented 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)) Commented 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...:( Commented Jan 24, 2013 at 17:48

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

1 Comment

That I did. I am going to go ahead and blame someone else for my mistake.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.