Automatically schedule a photos re-index on your Synology NAS to add missing images

If you've been having trouble getting Synology Photos to more consistently show newly added images and videos, this might be of use to you.

Automatically schedule a photos re-index on your Synology NAS to add missing images

The Synology Photos app that came with the big DSM7 upgrade is pretty nice overall. It bridges the gap between Synology Moments and PhotoStation and, even though I don't think it actually covers all of the same features, it creates a more coherent package, with a single place for you to find your photos. Whether they're imported phone snaps, family photos, or your DLSR archives.

If you're using the /photo shared directory to also manually add photos (or by using your own tools, importers, etc.), you might have noticed that these new photos don't actually always show up in Synology Photos, even with the indexing service configured to monitor the /photo shared directory.

It seems like Synology Photos's own indexer is not keeping track of file changes/additions, or if it does it doesn't seem to catch newly added files most of the time. In my situation I have noticed photos not showing up in Synology Photos even days after they have been added to the directory, so it clearly can be improved.

This is not at all an issue with File Station, of course, as the files immediately show up there. The problem is specific with Synology Photos not being aware of these new files.

Screenshot showing some photos in a grid. (actually this is from DSM7, but you get the idea)

Triggering a re-index seems to solve the problem, in that the images do show up eventually after running this. Even though it would be nice if Synology just figured this out by itself –there's built-in functionality for this very purpose in its underlying operating system, after all– it's at least far better than how Photo Station behaved under DSM6. I could never get it to even acknowledge images added outside of its own UI.

Even though a re-index solves this problem, it's of course less than ideal to have to manually trigger this every time you want to browse through your photos. Especially as the re-index itself can take quite some time to complete. While Synology does not offer an easy setting for this, there is a way we can use Task Scheduler and the synowebapi command line tool to achieve this ourselves.

Setting up a scheduled task

In case you've not used Synology's scheduled task functionality before, it can be found in your Control Panel, it's in the Services section and is called Task Scheduler. Open this, then click the Create > Scheduled Task > User-defined script.

In the following window, give the task a recognizable name (ie. Re-index Shared Photos), and set the user to root, as that's the only user that has permission to use the synowebapi command line tool we'll need to use.

Note: Triggering a re-index for your "personal space" and "shared space" are two separate actions. If you need to do both, you'll have to create two separate tasks.

Next, under the Schedule section, select the frequency with which you would like this command to run. Depending on your needs you can adjust the schedule to your liking, but keep in mind that this is probably not something you want to run all too often. One index can take quite some time to complete, and your NAS has limited resources.

In my case I set it to Daily, with the Frequency set to Every 12 hours and the Last run time set to 12:00. This way it basically runs a re-index twice daily.

Lastly, under the Task Settings section you can paste the following script in the User-defined script text field:

For re-indexing your Shared Space

synowebapi --exec api=SYNO.FotoTeam.Index version=1 method=reindex type=\"basic\"

For re-indexing your Personal Space

synowebapi --exec api=SYNO.Foto.Index version=1 method=reindex type=\"basic\"

With that in place, you can hit OK to save your task.

Knowing what's happening

As Synology's software is rather opaque when it comes to showing what's happening under the hood, it might not be entirely clear when something is happening. But it seems like the "Indexing..." status message does usually eventually show up in Synology Photos' settings panel, although it might take a bit after triggering the script before it does so, likely as the NAS internally uses a queueing system for these types of requests, too.

This is something to keep in mind, as this not showing up soon after triggering the command doesn't necessarily mean it didn't work. I'd recommend when you try triggering the task that you wait at least 5 minutes to see if something's happening.

If nothing shows up after quite some time, you can make use of the Send run details by email option under the Task Settings section of your task, which will use your Synology's email notification settings to send you an email. The response from the synowebapi command should be in the form of JSON data, and if successfull will show not much more than a success boolean, like so:

   "httpd_restart" : false,
   "success" : true

If your request returns anything else, there might be a typo in the command entered, or perhaps you tried to run the script as a user other than root. Double-check the task, making sure the escaped quotation marks are there exactly as shown above (it really has to be sent as \"basic\") and try again. There's a Run option by right clicking on any of the tasks to immediately trigger it.


And that should be it. Actual indexing time varies greatly depending on how many photos and videos you have of course, but from now on images and videos that have been added outside of using Synology's own apps will will start showing up following your defined schedule.