35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
import os
|
|
import subprocess
|
|
|
|
|
|
def create_folders(number_folders, base_path, verbosity=False):
|
|
"""creates an amount of folders and returning its path"""
|
|
|
|
if verbosity:
|
|
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")
|
|
else:
|
|
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)
|
|
|
|
|
|
def execute_as_subprocess(command, base_path, verbosity=False):
|
|
"""executes the string given with the '-c, --command' flag."""
|
|
if verbosity:
|
|
print(base_path)
|
|
print(command)
|
|
print(verbosity)
|
|
subprocess.run(command, cwd=base_path, shell=True)
|
|
else:
|
|
subprocess.run(command, cwd=base_path, shell=True)
|