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
  Help with creating folder and "virtual environment" AudunNilsen 1 171 Mar-21-2024, 04:41 AM
Last Post: deanhystad
Question How to add Python folder in Windows Registry ? Touktouk 1 207 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Create dual folder on different path/drive based on the date agmoraojr 2 378 Jan-21-2024, 10:02 AM
Last Post: snippsat
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 466 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Create Choices from .ods file columns cspower 3 520 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  Create SQLite3 database with peewee Jim53_1980 2 601 Dec-20-2023, 02:38 PM
Last Post: buran
  How to create a table with different sizes of columns in MS word pepe 8 1,417 Dec-08-2023, 07:31 PM
Last Post: Pedroski55
  I want to create one resume parser api using Python Flask parthsukhadiya 1 773 Nov-28-2023, 05:07 PM
Last Post: Pedroski55
  Recommended way to read/create PDF file? Winfried 3 2,786 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python convert multiple files to multiple lists MCL169 6 1,436 Nov-25-2023, 05:31 AM
Last Post: Iqratech

Forum Jump:

User Panel Messages

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