From dfe5ac300be255a4a08caf50677c35689a8baad9 Mon Sep 17 00:00:00 2001 From: Samuel Young <108681823+samyou-softwire@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:26:26 +0100 Subject: [PATCH] Create madlibs.py --- madlibs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 madlibs.py diff --git a/madlibs.py b/madlibs.py new file mode 100644 index 0000000..6110344 --- /dev/null +++ b/madlibs.py @@ -0,0 +1,22 @@ +import shutil, os, datetime + + +def date(filename: str) -> str: + return f"{datetime.datetime.now()} - {filename}".replace(":", " ") + + +def rename(file: str, path: str): + fullpath = os.path.join(path, file) + if os.path.isdir(fullpath): + for sub in os.listdir(fullpath): + rename(sub, fullpath) + + datedname = date(file) + print(datedname) + os.rename(fullpath, os.path.join(path, datedname)) + + +initialpath = input("Please input path: ") + +rename(initialpath, ".") +