Skip to content

Commit

Permalink
Delete working
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerem Kayacan committed Apr 14, 2019
1 parent 201a89e commit 1617c56
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
from datetime import datetime
from os import scandir
from send2trash import send2trash

def convert_date(timestamp):
d = datetime.utcfromtimestamp(timestamp)
formated_date = d.strftime('%d %b %Y')
formated_date = d.strftime('%d.%m.%Y %H:%M:%S')
return formated_date

def get_files():
dir_entries = scandir('D:\\home\\tmp')
for entry in dir_entries:
if entry.is_file():
info = entry.stat()
print(f'{entry.name}\t Last Modified: {convert_date(info.st_mtime)}')
info = entry.stat()
print(f'{entry.path}')
print(f'Last Modified: {convert_date(info.st_mtime)}')
print(f'Last Accessed: {convert_date(info.st_atime)}')
delta = (datetime.utcnow() - datetime.utcfromtimestamp(info.st_atime)).days
print(f'Days passed: {delta}')
if delta > 35:
send2trash(entry.path)
print(f'DELETE')
print(f'')

get_files()

0 comments on commit 1617c56

Please sign in to comment.