Automating a summary of new files

Each month I need to identify new documents within a group of nested folders (creation date between first and last date or the preceding calendar month), and then create an email to send to colleagues that lists the file name(s) (without extension) in a text outline which replicates the folder structure.

In a perfect world, I’d also like the text outline for each folder that contains new files to include a hyperlink to the corresponding folder on Box.com, but can live without this if that complicates the automation!

The files are stored in Box.com and are synced locally.

I have the usual macOS automation software (Hazel, Keyboard Maestro, etc) Any suggestions or ideas?

Thanks

Well the terminal’s pretty good for finding a list of files.

e.g. searching a user’s Desktop folders for files created last month.

#!/bin/zsh
FIRST=`date -v1d -v-1d +%Y/%m/01`
LAST=`date -v1d -v-1d +%Y/%m/%d`
find ~/Desktop/ -newerct $FIRST ! -newerct $LAST

Ref: date | find

I’m not sure if that newerct parameter is a > or >=, so you may need to tweak the date adjustments if by a day each way if the former.

After you get the list, it is just a matter of processing that output to remove the file extension, and there are dozens of ways to do that :wink:

Once you have your script, you could pop it into a Keyboard Maestro macro that takes the script output and puts it into a prepared e-mail for you with the expected recipients, etc.

Note, this does not cover the Box hyperlinking. I think you would need to start querying Box’s API to get that info. I don’t think I’ve seen any AppleScript or other local interfaces for it to get that stuff, and I think trying to get Keyboard Maestro to do it all in a manual sort of manner is liable to end up with all sorts of timing and navigation complexities.

I hope that gives you a worthwhile option to get you started.

That is really helpful thanks. I’ll give that a try. I m not sure what the line “Ref: date | find” is about below the terminal code box. Could you explain that for me?

Thank you again

They’re links with the man page for date and find along with some examples using these commands.

2 Likes