How to use a flow to automatically rename media files

Hi there,

I want to solve something about my nextcloud ( 21.0.7) setup which is bothering me for a while. I have an idea on how to do it and want to ask the community if this would work.

Problem:

When I auto-upload photos and videos from my phone, the names of these files will be slightly different depending from what source they came from, e.g. PXL_xyz.jpg or DSC_xyz.jpg.
Since there is no way for me to change these names, and all my names on my nextcloud server follow a consistent naming scheme, I want them to be renamed on the server right after they were uploaded.

I wrote a little command-line program that takes an image or video path and renames the file according to its metadata. That works locally on my machine fine.

Now I would like to tell Nextcloud to do the following:

  1. Whenever a new file arrives in any sub-directory of my custom photo directory /xyz/cameraroll,
  2. If this file is of type: [x, y, z, …]
  3. Call my program with this file as argument: my_program rename path_of_new_file

Step 2 is optional since my program already checks the file extensions which I am interested in.

Now I looked around and it seems that Nextcloud Flows is what I am looking for.

So in my mind I can simply upload my program to my server, make it available system-wide so my nextcloud docker instance can use it. Then create a new flow that just includes a call to my program.

And then how do I tell it to run over my photo directory?
Will this mess with the database?
Any other stumbling stones anyone can see here?

1 Like