Automatically copy and convert photos and videos

I have a large picture and video collection in my Nextcloud.
According to the schma: “event/person/media.hevc|.heic”.

Since not all devices can read the new codec I still have to convert them (manually) and share it with other people.

For this I wrote a (shell) script that copies photos and videos including folder structure into a new folder and converts and scales the media. But this runs manually on my client PC, with Nextlcoud client (so it must be on).

Is there a way to do the copying and converting automatically?
Or is there a way to run my script automatically on the server (one to always run a --files-scan)?

Server and client Ubuntu.

Thanks a lot.

can you send that shell script over?