Transfer ownership with spaces in path name

The following command:

occ files:transfer-ownership --path "Project 1" test.user1 rob.nicholson

Produces this error:

Too many arguments to “files:transfer-ownership” command, expected arguments “source-user” “destination-user”.

I’ve just successfully done a transfer with a folder called Transfer1, i.e. without any spaces in the path. Try “Project1” and no error but of course warning that path doesn’t exist. I found a github issue around this but it was closed without resolution.

How you do transfer ownership of a folder with spaces in the path?

This post from 5 years ago has a similar problem with spaces in the username. Not my problem but related?

https://help.nextcloud.com/t/how-to-use-files-transfer-ownership-command-using-users-that-has-space-on-it/46106

I tried on NC 28.0.1 with a folder Project 1 like you have:

php occ files:transfer-ownership --path "Project 1" user1 user2

and it works. Not sure if you perhaps need to put the usernames in quotes as well because of the point (like for a user with space: https://github.com/nextcloud/server/issues/14051#issuecomment-461718003)?

Found my problem and it’s not an issue with Nextcloud. Your reply pointed me towards the fault. I’ve got a bash script called nextcloudcmd that contains this:

#!/bin/bash
sudo -u nginx php --define apc.enable_cli=1 /data/nextcloud/$*

In an attempt to stop me having to type in all that pre-amble that I can never remember :slight_smile: So I can type nextcloudcmd occ groupfolders:list

This doesn’t work with this specific occ transfer-ownership command. I’m guessing the $* expansion in the script isn’t working quite as expected. When I run the entire command manually, it works:

sudo -u nginx php --define apc.enable_cli=1 /data/nextcloud/occ files:transfer-ownership --path “Project 1” test.user1 rob.nicholson

Preservation of quoted strings is a perennial problem with scripting!

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.