OCC "command not found" or "Command is not defined"

It’s been a while, but I faced same issue in latest Nextcloud releases. Check, if you had enabled maintenance-mode occ maintenance:mode --on
This was in my case. So turn off maintenance-mode occ maintenance:mode --off, you can access the occ files:scan --all command.
I don’t know the reason, but in active maintenance-mode, you do not have the files-commands available. :thinking: