Created
August 22, 2021 04:43
-
-
Save Mahrjose/afc595c9c2462cf74c699a0a018b1af1 to your computer and use it in GitHub Desktop.
Script for creating multiple files at once in a specific directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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