-
Notifications
You must be signed in to change notification settings - Fork 1
/
files_directories.py
45 lines (38 loc) · 1.26 KB
/
files_directories.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Aeriel Denmark
# Files and Directories
import os
import datetime
import os.path
import shutil
# 'shutil' helps to automate copying files and directories; saves the steps of opening, reading,
# writing and closing files when there is no actual processing
path = os.path.expanduser("~/Desktop") # Program cannot identify path
os.chdir(path) # This is where the error occurs"
w = "Wakanda Forever/"
currentDT = datetime.datetime.now().strftime("%m/%d/%Y - %H:%M")
template = """
<!DOCTYPE html>
<head>
</head>
<body>
</body>
</html>
"""
if os.path.exists(w):
print("It exists")
os.chdir(w) # change user's directory to wanted directory
print(cwd) # necessary for trobleshooting purposes
f = open("index.html", "w+")
f.write(currentDT)
f.write(template) # not sure why error occurs at this point
f.close()
else:
print("It does not exist.")
print("")
os.mkdir(w) # make the directory on the user's desktop
os.chdir(w) # change directory to newly created directory on user's desktop
print("Directory Created.") # necessary checkpoint in troubleshooting process
f = open("index.html", "w+")
f.write(currentDT)
f.write(template) # not sure why error occurs at this point
f.close()