I have a camera setup up to take an image every few seconds and then the image is processed and is no longer required. Can anyone help me to write a script/service that will delete files/images in a folder that are older than 3 hours? I'm trying to do this as it takes a ton of space if only purged every 24 hours using Automator.
macOS – Automatically Delete Files Older Than 3 Hours
macos
Related Question
- MacOS – Best way to back up old CD-ROMS
- MacOS – Changing the background image in all spaces
- MacOS – iTunes now takes up 100% of CPU since updating to 11.3
- MacOS – Old MacBook Pro 17″ freezes when WiFi gets turned off
- MacOS – How to have Finder open ‘Pictures’ folder when iPhone connects and photos import via AutoImporter.app
- MacOS – Bash script – Delay cp command until after file write is complete
- Split CSV File Using Automator Service in Finder
- MacOS – An automator service that opens a file with the same name but different extension of the selected item
Best Answer
Here is an example
find
command that you can modify to suit your needs:I'd use
launchd
to run it every 3 hours.Here is an example
.plist
file that will run thefind
command every 3 hours usinglaunchd
:It would be saved in:
$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist
From Terminal:
/path/to/files/
to the actual path.*.jpg
to the proper extension if not:jpg
Continue in Terminal, to load the
plist
file:To
stop
andunload
the"$HOME/Library/LaunchAgents/com.my.delete.every.three.hours.plist"
file use: