From f2f4a134b49e06427fa91d27542a35aa6353f4e3 Mon Sep 17 00:00:00 2001 From: mursalatul Date: Sun, 31 Mar 2024 04:11:03 +0600 Subject: [PATCH] fix dir deletion problem --- clean_windows_temp/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clean_windows_temp/main.py b/clean_windows_temp/main.py index b29adf0..d906cf3 100644 --- a/clean_windows_temp/main.py +++ b/clean_windows_temp/main.py @@ -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 @@ -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) @@ -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 """