-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_browser_temp.py
More file actions
27 lines (23 loc) · 836 Bytes
/
clean_browser_temp.py
File metadata and controls
27 lines (23 loc) · 836 Bytes
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
import os
import shutil
import sys
# Paths for Chrome and Edge cache on Windows
BROWSER_PATHS = {
'Chrome': os.path.expandvars(r'%LOCALAPPDATA%\Google\Chrome\User Data\Default\Cache'),
'Edge': os.path.expandvars(r'%LOCALAPPDATA%\Microsoft\Edge\User Data\Default\Cache'),
}
def clean_cache(path, browser_name):
if os.path.exists(path):
try:
shutil.rmtree(path)
print(f"{browser_name} cache cleaned: {path}")
except Exception as e:
print(f"Failed to clean {browser_name} cache: {e}")
else:
print(f"{browser_name} cache folder not found: {path}")
def main():
for browser, path in BROWSER_PATHS.items():
clean_cache(path, browser)
print("Cleaning complete. Please restart your browsers if they are open.")
if __name__ == "__main__":
main()