Last active
April 22, 2019 08:22
-
-
Save wwwins/178f0ff0b839584d73386b0d81485d12 to your computer and use it in GitHub Desktop.
Count files in folder
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
#!/usr/bin/env python2 | |
# | |
# Copyright 2019 isobar. All Rights Reserved. | |
# | |
# Count files in folder | |
# | |
# Usage: | |
# image-cnt.py public/upload | |
# | |
import os | |
import sys | |
import time | |
import glob | |
def main(folder): | |
file_cnt_by_date = {} | |
files = glob.glob(folder+'*') | |
for f in files: | |
ftime = time.gmtime(os.path.getmtime(f)) | |
mon = '0'+str(ftime.tm_mon) | |
day = '0'+str(ftime.tm_mday) | |
hour = str(ftime.tm_hour) | |
minutes = str(ftime.tm_min) | |
#print(mon+day+' '+hour+':'+minutes+'\t'+f) | |
key=mon[-2:]+day[-2:] | |
if key in file_cnt_by_date: | |
file_cnt_by_date[key] = file_cnt_by_date[key]+1 | |
else: | |
file_cnt_by_date[key] = 1 | |
print('Date:\tCount') | |
for i in sorted(file_cnt_by_date): | |
print(i+':\t'+str(file_cnt_by_date[i])) | |
folder = sys.argv[1] | |
main(folder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment