Retrospectively organize already uploaded photos into subfolders?

I’m using Nextcloud AIO on my Debian server and have synchronized around 30,000 photos from my mobile device into one folder. Opening this main photo folder has become very slow due to the large number of files.

I noticed the Nextcloud mobile app has an auto-upload feature that organizes new photos into subfolders by date. Is there any way to apply this automatic subfolder sorting retrospectively to the photos I’ve already uploaded?

Any guidance or recommendations would be greatly appreciated.

Thanks!

Okay, here is my janky solution.

  1. Mirror files using nextcloud client onto your device
  2. Execute the following which prefers the most reliable “created” timestamps
exiftool -d "%Y" \
  "-Directory<FileModifyDate" \
  "-Directory<CreateDate" \
  "-Directory<DateCreated" \
  "-Directory<DateTimeOriginal" \
  /path/to/your/files