Python Forum
How can I create a new folder, then create multiple new files in that folder?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I create a new folder, then create multiple new files in that folder?
#1
name = input ("what is your name?")
cupcakes = int(input ("How Many Cupcakes did you eat?"))
calories = 300
calMath = (calories * cupcakes)
totalCal = (0)

Create New Folder (name)
While totalCal < calMath
make a new file in new folder with (name+totalCal".txt")
totalCal = (totalCal + calories)

I want this while loop to keep making new files in the new folder until the loop is complete.
Reply
#2
have a look at os.mkdir() and os.mkdirs()
https://docs.python.org/3/library/os.html

if you prefer OOP - Pathlib also has Path.mkdir method
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to create a moving average backward of a serie of sumbers? Frankd 5 215 9 hours ago
Last Post: Frankd
  how to create video game mission chart?[SOLVED] kucingkembar 1 175 Jun-19-2024, 02:11 PM
Last Post: kucingkembar
  I dont understand on how to create a Bot that can read info on the screen aloud RaySuS777 0 150 Jun-19-2024, 10:02 AM
Last Post: RaySuS777
  Delete file with read-only permission, but write permission to parent folder cubei 6 22,465 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
  Trying to generating multiple json files using python script dzgn989 4 413 May-10-2024, 03:09 PM
Last Post: deanhystad
  How does this code create a class? Pedroski55 6 759 Apr-21-2024, 06:15 AM
Last Post: Gribouillis
  Deleting Windows temp folder Raysz 7 748 Apr-02-2024, 12:36 PM
Last Post: Raysz
  Help with creating folder and "virtual environment" AudunNilsen 1 351 Mar-21-2024, 04:41 AM
Last Post: deanhystad
Question How to add Python folder in Windows Registry ? Touktouk 1 425 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Create dual folder on different path/drive based on the date agmoraojr 2 647 Jan-21-2024, 10:02 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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