Auto Clean up old recordings

Some time ago, I bought the Netatmo Presence cam. 
I love the "Intelligence" in the cam (it detects different objects linke cars, people, animals), and it's ability, to work when there is no wifi etc. due to the build in SD card.
I do however, upload everything to my NAS using ftp, for safe keeping.

My settings, is to keep everything for 30 days. That's more than enough, and something the Netatmo supports -  or so I thought. 

It turns out, that the uploaded data, is not deleted after 30 days, so to keep myself from storing tons of old video files, I decided to use the build in scheduled tasks in my Synology, todo some cleanup.

Everything is keept in a folders called Cam, on the Synology.
And it's stored in a folder structure like year -> month -> date -> File

So the solution was rather easy.

Create a task in the Synologt DSM interface, that runs every day at 23:59 (sorry for the danish screenshot).

Run the script :

find '/volume1/cam/' -mtime +30 -type f -delete
find '/volume1/cam/'  -type d -empty -delete

The 1 line find's all files, in the folder structure, that is older then 30 days and deletes them.
The 2 line, find's all empty folders, and deletes them.

This could probably have been done smarter, but this seam to work.

Right now it sends a notification to me after each run.
When i know it runs perfectly, i will chose to only receive email, when it ends with errors.