Rclone rcd HTTP POST sync/copy doesn't preserve source directory (create a top-level directory)

What is the problem you are having with rclone?

I'm using HTTP POST to control my remote rclone rcd server, and I expect it to work the same as running rclone copy source/to/directory dest:/, which creates dest:/directory, and copies the file inside. But it actually got dest:/{other files under directory} without creating a top-level directory.

Run the command 'rclone version' and share the full output of the command.

rclone v1.67.0
- os/version: Microsoft Windows 11 Pro 23H2 (64 bit)
- os/kernel: 10.0.22631.4037 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.22.4
- go/linking: static
- go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

Microsoft OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

I run rclone rcd:

rclone rcd --rc-user=admin --rc-pass=secret --rc-addr=localhost:5572

And my http post request: ( using java):
createEmptySrcDirs both true and false are tried.

public static boolean copy(String src, String dst) {
        String host = ConfigUtil.CONFIG.getRcloneHost();
        String username = ConfigUtil.CONFIG.getRcloneuserName();
        String password = ConfigUtil.CONFIG.getRclonePassword();
        JsonObject obj = new JsonObject();
        obj.addProperty("srcFs", src);
        obj.addProperty("dstFs", dst);
        obj.addProperty("createEmptySrcDirs", true);
        try {
            return HttpRequest.post(host + "/sync/copy")
                    .basicAuth(username, password)
                    .header("Content-Type", "application/json")
                    .body(GsonStatic.toJson(obj))
                    .thenFunction(res -> {
                        Assert.isTrue(res.isOk(), res.body());
                        log.info("rclone copied src: {}, dst: {}", src, dst);
                        return true;
                    });
        } catch (Exception e) {
            log.error("rclone copy error: {}", e.getMessage());
            return false;
        }
    }

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

Paste config here

A log from the command that you were trying to run with the -vv flag

Paste  log here

welcome to the forum,

should rclone selfupdate and test again.

Thanks for your reply.
Now I've updated to the latest version (v1.69.2), but still not work as expected.

if i understand correctly, that is not how rclone works.


### create a simple test enviroment.
rclone touch source/to/directory/file.ext

rclone tree .
/
└── source
    └── to
        └── directory
            └── file.ext


### copy command as you ran it.
rclone copy source/to/directory dest/

rclone tree .
/
├── dest
│   └── file.ext
└── source
    └── to
        └── directory
            └── file.ext			


### copy command as i think you want it
rclone copy source/to/directory dest/directory

rclone tree .
/
├── dest
│   └── directory
│       └── file.ext
└── source
    └── to
        └── directory
            └── file.ext

Ohh yes, that's right. I was wrong. I think rclone copy src/dir dest:/ to create dir in dest, and end with /, i.e, rclone copy src/dir/ dest:/ to copy files inside dir to dest is a good feature.

from the rclone docs
Note that it is always the contents of the directory that is synced, not the directory itself..