20 lines
511 B
Python
20 lines
511 B
Python
|
|
import tempfile
|
||
|
|
import os
|
||
|
|
|
||
|
|
|
||
|
|
def create_folders(number_folders, base_path):
|
||
|
|
"""creates an amount of folders and returning its path"""
|
||
|
|
while number_folders > 0:
|
||
|
|
number_folders = number_folders - 1
|
||
|
|
|
||
|
|
folder_name = f"folder_{number_folders}"
|
||
|
|
full_path = os.path.join(base_path, folder_name)
|
||
|
|
|
||
|
|
os.mkdir(full_path)
|
||
|
|
print(f"'{full_path}' was created")
|
||
|
|
|
||
|
|
|
||
|
|
# Creates a temporary directory.
|
||
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||
|
|
print(f"Folderpath: {temp_dir}")
|