Custom Script to Safely Use Lightroom Classic with Nextcloud Sync

I use Lightroom Classic with my Nextcloud setup and only sync .lrcat and .lrcat-data files. The issue is that opening a catalog before or during synchronization can lead to data corruption.

Initially, I considered stopping sync based on a LOCK file, but it seems simpler to pause the Nextcloud app while Lightroom is open. To achieve this, I want to create a custom batch file that:

  1. Checks the most recent log file in %USERPROFILE%\AppData\Roaming\Nextcloud\logs to ensure it’s 0 bytes (indicating sync is complete).
  2. Closes the Nextcloud app.
  3. Launches Lightroom.
  4. Monitors Lightroom’s activity and automatically restarts the Nextcloud app once Lightroom is closed to resume synchronization.

Approach: A PowerShell script integrated with a batch file will check if the latest log file in %USERPROFILE%\AppData\Roaming\Nextcloud\logs is empty and, if so, stop Nextcloud and start Lightroom. The script will also track Lightroom’s status and restart Nextcloud once the application is closed. This prevents potential conflicts or corruption by ensuring no sync is active when Lightroom opens.

This approach automates workflow and minimizes the risk of catalog corruption. Would appreciate any feedback or improvements!

This does not deal with problems from Simultaneous Access: If another user opens or modifies the catalog while it is open in Lightroom or while Nextcloud syncing is paused, changes made by that user won’t be synced back until Nextcloud is restarted.