From 681f434386361006fee6d0913caf90202a1d2e16 Mon Sep 17 00:00:00 2001 From: VanillaHellen Date: Mon, 25 Jan 2021 16:25:31 +0100 Subject: [PATCH] now adding timestamp --- win_venv/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/win_venv/main.py b/win_venv/main.py index 5f431b4..6b5c83a 100644 --- a/win_venv/main.py +++ b/win_venv/main.py @@ -23,9 +23,17 @@ def files(path): yield os.path.join(subdir, file) def save_input(oldpath): - # make timestampt the filename, so it wouln't overwrite + # add timestamp to the filename, so it wouln't overwrite but the user still knows which file's which timestamp = str(int(time.time())) - filename = timestamp + '.' + oldpath.split('.')[-1] + basename = os.path.basename(oldpath) + try: + basename.index('.') + basename_no_extension = basename[:basename.index('.')] + extension = basename[index_of_dot:] + except ValueError: + basename_no_extension = basename + extension = '' + filename = basename_no_extension + '_' + timestamp + extension newpath = inputFilePath + '\\' + filename shutil.copy(oldpath, newpath) return newpath -- 2.20.1