Skip to content

Instantly share code, notes, and snippets.

@Mahrjose
Created August 22, 2021 04:43
Show Gist options
  • Save Mahrjose/afc595c9c2462cf74c699a0a018b1af1 to your computer and use it in GitHub Desktop.
Save Mahrjose/afc595c9c2462cf74c699a0a018b1af1 to your computer and use it in GitHub Desktop.
Script for creating multiple files at once in a specific directory.
from pathlib import Path
def fileMaker(start, end, name, extension, folder_path) -> None:
path = Path(folder_path)
if path.exists() and path.is_dir():
for serial in range(start, end + 1):
file_name = f"{name} {serial:0>2d}{extension}"
file = path.joinpath(file_name)
with open(file, "w") as f:
f.close()
# Fill these out if you want to change something
start = 1
end = 17
name = "Problem"
extension = ".py"
folder_path = input("Folder Path: ")
# Function call
fileMaker(start, end, name, extension, folder_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment