Checking for folder/file changes using Automator

automatorfinderfoldersscript

Is there there a way to check a folder/file for changes (includes adding files, deleting files, changes in files,…). The 'Folder action' in Automator is only checking if any files are newly added.

Best Answer

You can add a "Run Shell Script" action with the command:

find <directory> -newermm <reference_file>

This will give you all files and directories inside <directory> that have changed since the last change of <reference_file>. Just make sure you modify the <reference_file> each time you run the Automator script.

Also give a look to the find manual page (enter man find in the terminal) for more options. Find is very powerful and further refining your search is usually a matter of a couple of additional options. E.g. to search only for directories modified after <reference_file>:

find <directory> -type d -newermm <reference_file>

If the version that ships with OSX is not enough, you can also try the version that comes with findutils (brew, macports etc) which should have slightly more features.