Skip to content

Commit

Permalink
fix dir deletion problem
Browse files Browse the repository at this point in the history
  • Loading branch information
mursalatul committed Mar 30, 2024
1 parent 0428972 commit f2f4a13
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions clean_windows_temp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class Cleaner:
windows_temp_path = 'C:\\Windows\\Temp'
user_temp_path = 'C:\\Users\\mursa\\AppData\\Local\\Temp'
windows_temp_path = 'D:\\Programming_related\\PROJECTS\\ALL_PROJECT\\mini-projects\\clean_windows_temp\\test'

def __init__(self) -> None:
pass
Expand All @@ -16,13 +17,10 @@ def clean_w_temp(self) -> bool:

# setting the current working directory into windows_temp_path
os.chdir(self.windows_temp_path)

with os.scandir(os.getcwd()) as contents:
for content in contents:
# change mode to read write execution
# os.chmod(content.name, 0o755)
for content in contents:
try:
if content.is_file:
if content.is_file():
os.remove(content.name)
else:
os.rmdir(content.name)
Expand All @@ -46,6 +44,9 @@ def clean_all(self) -> bool:
self.clean_w_temp()
self.clean_u_temp()

# def remove_dir(self, dir_path):


def main():
"""the main function
"""
Expand Down

0 comments on commit f2f4a13

Please sign in to comment.