-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoveOutputFile.py
30 lines (24 loc) · 1.02 KB
/
moveOutputFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3.8
# i have no clue why i made this when i made this lmao
import datetime, os, shutil, string
today = datetime.datetime.now()
month = today.strftime("%B")[:3]
date = today.strftime("%d")[:3]
newFileName = month.lower() + date
# os.chdir("C:/users/firoz/Desktop")
destinationFolder = "oldoutputfiles"
existingFiles = [f for f in os.listdir(destinationFolder) if os.path.isfile(os.path.join(destinationFolder, f))]
if any(newFileName in oldFilenames for oldFilenames in existingFiles):
alphabets = list(string.ascii_lowercase)
oldFileNames = []
for fileName in existingFiles:
if newFileName in fileName:
fileSuffix = fileName[-5]
newFileSuffix = alphabets[(alphabets.index(fileSuffix) + 1)]
finalFileName = f"{newFileName}{newFileSuffix}.txt"
else:
finalFileName = f"{newFileName}a.txt"
print(f"{finalFileName} created.")
shutil.move('output.txt', f'oldoutputfiles/{finalFileName}')
# shutil.copyfile('output.txt', f'oldoutputfiles/{finalFileName}')
# os.remove("output.txt")