FilesByWeek

FilesByWeek is a Linux shell (bash) script that lets you check how many files in a directory were created (or last modified) in a certain week of the year, using Linux’s find and date.

It was designed to count the number of emails received in a few Linux/Postfix Maildirs every week (and thus excludes .Sent and any Courier/Dovecot IMAP files), but can be used on any kind of folder.

Download

Platform Version Package Size
Linux 1.0 – 2009-06-20 filesbyweek.sh (right-click -> Save as…) 3.2 KB
Git repository Development https://github.com/patrickmn/filesbyweek

Usage

./filesbyweek <week> [dir]

Examples:

  • ./filesbyweek 24 — scans the current directory for files created in week 24.
  • ./filesbyweek 24 /var/mail/[email protected] — scans /var/mail/[email protected] for files/emails created/received in week 24.

Requirements

  • Linux with bash, date, and find (all available in most distributions).

Notice

  • If the script won’t run, make it executable with the command: chmod +x filesbyweek.sh
  • The date command used in FilesByWeek considers Monday the first day of the week. If you would like Sunday to be the first day of the week, change %W to %U within the date call inside the script.
  • date starts counting weeks on the first Monday (or Sunday) in a new year, which we work around by subtracting 1 from the week count inside the script. However, if the year actually does start on a Monday, you should comment out WEEK=$((WEEK-1)) inside the script.

License

FilesByWeek is released under the MIT license.