Help with the occ command

I’m trying to have ownership from all user shares to mine (Admin).

But I realized some users have space in their usernames. That way, I’m not able to transfer via SSH, I need to escape the spaces, otherwise I get messages like:

Too many arguments, expected arguments "command" "source-user" "destination-user".

I tried:

sudo -u web-user path/to/php path/to/occ files:transfer-ownership User with space Admin
sudo -u web-user “path/to/php” “path/to/occ” files:transfer-ownership “User with space” Admin
sudo -u web-user “path/to/php” “path/to/occ” files:transfer-ownership User\ with\ space Admin
sudo -u web-user path/to/php path/to/occ files:transfer-ownership “User\ with\ space” Admin

None of them seem to work. Any idea?

Try this

sudo -u web-user path/to/php path/to/occ files:transfer-ownership """User with space""" Admin`

Didn’t work. Any other possible command?

No sorry, this worked for me… There are errors because I used fake users but the occ command is understood.

sudo -u www-data php /var/www/nextcloud/occ files:scan -v """user with space""" otheruser
Unknown user 1 user with space

Unknown user 2 otheruser

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+

Scan works, but not for transferring ownership command. I need to escape the space on the username and haven’t done so far, I’ve tried lots of combinations. Please give it a try on the files:transfer-ownership command.

Sorry, I thought this could have solved your issue. I just created a user with space to test and that doens’t work for transferring ownership. I have the same error message :frowning:

Do you know any workaround? I really need this.

No I have no idea how to do this with occ command.

Maybe it’s possible to modify the database to do what you want but you’ll need to find someone who has a perfect knowledge of its structure.

Because this kind of operation is very dangerous don’t forget to backup your Nextcloud installation before…