Created
September 17, 2018 10:39
-
-
Save shoter/6f9e0e774703cf19eca744528b27581c to your computer and use it in GitHub Desktop.
Simple File deleter for windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, time, sys | |
from win10toast import ToastNotifier | |
toast = ToastNotifier() | |
def str_join(*args): | |
return ''.join(map(str, args)) | |
def warnAboutOldFiles(path, days): | |
path = "C:\\Users\\damian_laczak\\Downloads" | |
now = time.time() | |
fileCount = 0 | |
for f in os.listdir(path): | |
fullPath = os.path.join(path, f) | |
if os.stat(fullPath).st_mtime < now - (days * 86400): | |
fileCount = fileCount + 1 | |
if fileCount > 0: | |
toast.show_toast("Delete notifier", str_join(path, "\nYou have ", fileCount, " files that are at least ", days, " days old")) | |
def deleteOlderFielsThan(path, days): | |
path = "C:\\Users\\damian_laczak\\Downloads" | |
now = time.time() | |
for f in os.listdir(path): | |
fullPath = os.path.join(path, f) | |
if os.stat(fullPath).st_mtime < now - (days * 86400): | |
if os.path.isfile(fullPath): | |
os.remove(os.path.join(path, fullPath)) | |
def warnAndDelete(path, daysWarn, daysDelete): | |
warnAboutOldFiles(path, daysWarn) | |
deleteOlderFielsThan(path, daysDelete) | |
warnAndDelete("C:\\Users\\damian_laczak\\Downloads", 60, 90) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment