Python Forum
Creating multiple folders and other questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating multiple folders and other questions
#3
(Aug-19-2018, 06:43 PM)ichabod801 Wrote: The only way I can think of to make this code simpler is to use a loop:

for dir in ('Maps', 'Sounds', 'Music', 'Textures'):
    os.mkdir(dir)
os.makedirs failed because it makes directories down the file tree (as needed), not across it. So it makes a Maps directory, then a Sounds directory in the Maps directory, and so on.

Hi there

Big thanks for the reply. I'm not familiar with loops but will look into it. Just tested your code and it works perfectly. I understand your explanation of makedirs and why it failed - thank you. Baby steps for me Smile
Reply


Messages In This Thread
RE: Creating multiple folders and other questions - by coder2be - Aug-19-2018, 06:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Prevention of deleting and creating folders kayak88 1 549 Mar-10-2025, 02:19 PM
Last Post: DeaD_EyE
  sub-folders in folders from text line jenost 1 2,160 Mar-31-2020, 07:16 AM
Last Post: ndc85430
  Creating multiple lists from file without long for loop Curtnos 2 5,636 Jan-28-2018, 09:11 AM
Last Post: Gribouillis
  Netmiko - add multiple files, from different folders to mail. tomikovaknin 5 6,533 Nov-26-2017, 12:55 PM
Last Post: heiner55
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 56,662 Nov-25-2017, 06:21 AM
Last Post: heiner55
  Creating folders dynamically with year/month/date sritsv 0 7,253 Oct-16-2017, 03:44 PM
Last Post: sritsv
  Creating multiple text fies from new url retrieve results wmc326 1 3,755 Jul-13-2017, 10:57 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020