In order to organize an ownCloud upload folder with lots of files, I created new folders for each year manually on the server and moved files over in the terminal.
Of course ownCloud didn't know about those moved files and still expected them to be at their original location afterwards.
In order to make the moved files known to ownCloud, I ran file:scan for each new folder:
sudo -u nginx php /var/www/owncloud/occ files:scan -p /myuser/upload/2022 -v
And in order to get rid of the old file references, I ran the same command with the repair option for the parent folder:
sudo -u nginx php /var/www/owncloud/occ files:scan -p /myuser/upload -v --repair
This worked so far, but for some reason I wasn't able to upload additional files into those year specific folders. File permissions on the server seem to be correct, to I checked the oc_filecache table in the DB.
It turned out that the records for the folders hat column permissions = 17 (read access) while originally created folders in ownCloud had permissions = 31.
Changing the records for those folder records into permissions = 31 fixed the file upload problem.