Automatically delete files older than 3 hours macOS
Here is an example find command that you can modify to suit your needs:
find '/path/to/files/' -type f -name '*.jpg' -mmin +180 -delete

I'd use launchd to run it every 3 hours.
Here is an example .plist file that will run the find command every 3 hours using launchd:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.my.delete.every.three.hours&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/bin/find&lt;/string&gt;
        &lt;string&gt;/path/to/files/&lt;/string&gt;
        &lt;string&gt;-type&lt;/string&gt;
        &lt;string&gt;f&lt;/string&gt;
        &lt;string&gt;-name&lt;/string&gt;
        &lt;string&gt;*.jpg&lt;/string&gt;
        &lt;string&gt;-mmin&lt;/string&gt;
        &lt;string&gt;+180&lt;/string&gt;
        &lt;string&gt;-delete&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;10800&lt;/integer&gt;
&lt;/dict&gt;
&lt;/plist&gt;

It would be saved in: $HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist
From Terminal:
touch &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot;
open -e &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot;


Copy and paste example XML code into the opened TextEdit document:
Modify as needed:

E.g. Change /path/to/files/ to the actual path.
E.g. Change *.jpg to the proper extension if not: jpg


Save and close the document.

Continue in Terminal, to load the plist file:
launchctl load &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot;

To stop and unload the &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot; file use:
launchctl stop &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot;
launchctl unload &quot;$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist&quot;