-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kerem Kayacan
committed
Apr 14, 2019
1 parent
201a89e
commit 1617c56
Showing
1 changed file
with
12 additions
and
4 deletions.
There are no files selected for viewing
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
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() |