Count number of files in a folder per day

You can do this using the printf action of find to print only the modification times in desired format, and then using sort and uniq:

find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
  • -printf '%TY-%Tm-%Td\n' prints the modification time of files in e.g. 2015-05-23 format

  • sort sorts the output and uniq -c does the count by date

Example:

~/foobar% find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
      3 2004-06-29
      1 2004-08-23
      1 2004-09-15
      1 2004-09-18
      1 2005-07-24
      1 2006-02-05
      2 2008-06-25
      3 2008-12-31
      1 2009-03-13
      1 2009-04-30
      1 2010-04-04
      2 2010-09-01
      8 2011-07-13
     15 2011-08-27
      3 2011-11-03
      3 2014-10-08

Here's a solution with find + awk

find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val]   }'

Essentially what happens is that we find all regular files and print their modification time as specified by the %T format , and then awk takes over , and counts each line using associate arrays . the END{} statement uses for loop to go through all the elements in the associated array, and print key + array[key] contents ( which is the date + count ).

You may want to use sort to organize the output , particularly sort -k 1 based on column 1 (which is date), but that is optional. Also -maxdepth 1 will check for files only in the current folder. If you want to find files in subdirectories as well, remove -maxdepth 1 part.

Sample output

$ find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val]   }'

2015-09-29 1
2016-04-06 2
2016-04-07 10
2016-04-08 2
2015-11-05 2
2016-04-22 2
2016-04-23 6
2016-04-24 1
2015-11-21 2
2015-11-22 2