Skip to content

add new commands that mimic unix cp/mv #4777

Open

Description

@ivandeex

rclone copy and rclone move diverge in syntax and semantics from their unix counterparts. There are good reasons (efficiency and primary rclone function as a cloud tool) for why rclone move and rclone copy behave the way they do at the moment. Changing them would break many rclone based workflows in the wild.

Let's add new rclone mv and rclone cp which behave exactly like their unix counterparts. One of the things that would be required for these is multiple source parameters.
Originally submitted by @ncw at #4308 (comment)

The implementation details have been discussed in #4308

The all new rclone cp would support a flag like --recurse (or even -R) with semantics close to cp -R (TBD).
Originally submitted by @mrmcmuffinz at #1228 (comment)

A similar request #4776 adds rsync specifics on top of these requirements.

Activity

  1. ncw commented on Dec 7, 2020

    @ncw
    Member

    @GG-Sheridan

    Should this issue be labeled as Good First Issue?

    No. It is quite tricky to replicate the features of cp/mv and to do so properly would require a lot of knowledge of rclone internals too.

  2. ivandeex commented on Feb 12, 2021

    @ivandeex
    MemberAuthor

    Rephrasing requirements from #1175 in context of this feature request:

    Currently moveto does not support moving files to an existing directory.
    On the contrary, rclone mv should re-create the semantics of mv. Essentially these should move the file(s) into existing directory:

    rclone mv file... existingdir
    rclone mv file... existingdir/
    

    (moveto would delete empty existing dir and rename file to that name, or fail if it's not empty)

    A similar reasoning holds for rclone cp vs copyto.

  3. ivandeex commented on Feb 12, 2021

    @ivandeex
    MemberAuthor

    From #2629

    As per documentation the following sequence of commands will not try to copy empty directory, just print an informational message

    mkdir -p src/a
    mkdir dst
    rclone copyto src/a dst/a
    

    On the contrary, the command

    rclone cp --recursive src/a dst/a
    

    should rather create empty directory on target side (the flag name is tentative).

  4. ivandeex commented on Mar 31, 2021

    @ivandeex
    MemberAuthor

    Currently rclone treats metacharacters (*?) in source file name as part of the name. The new commands will treat them as globs similar to (and on top of) source filter arguments like --include or --exclude.

    There is a trick, though. If rclone is run interactively Unix(bash/*sh), user must properly escape metachars to prevent shell globbing and let rclone do the local or remote listing with globbing/filtering and apply many other filtering options.

    If source is local then shell globbing would be ok if we allow the new cp/mv (and rsync) verbs to have more arguments than just source and destination so the following command

    rclone cp /dir/prefix* backend:bucket/path/
    

    will be expanded by the shell to

    rclone cp /dir/prefix_file1 /folder/prefix_file2... backend:bucket/path/
    

    and rclone will copy all sources.

  5. Exagone313 commented on Feb 12, 2024

    @Exagone313

    I think rclone should have a command that has a behavior similar to rsync. The latter has some specifics about trailing slashes that are important to decide how to transfer files.

    EDIT: Didn't see that's what the mentioned issue just above is about.

  6. davinkevin commented on Dec 30, 2024

    @davinkevin

    question is this still plan at some point? I use rclone as an rsync replacement, and it's a pain to deal with this limitation.

    Currently, I run something like this, kind hacky but it does the job:

    fd --exact-depth 1 folderS-I-want --threads=1 --exec rclone copyto --progress {} <dest>:/remote-folder/
    

    However, rclone is damn good, and just the fact to have the config saved somewhere is for me the killing feature.

  7. ncw commented on Dec 31, 2024

    @ncw
    Member

    Currently, I run something like this, kind hacky but it does the job:

    fd --exact-depth 1 folderS-I-want --threads=1 --exec rclone copyto --progress {} <dest>:/remote-folder/
    

    Can you @davinkevin explain exactly what that does? I can then see if I can replicate with rclone as running lots of individual rclone commands is inefficient and you are losing the opportunity for concurrency.

  8. davinkevin commented on Dec 31, 2024

    @davinkevin

    In a folder with 10 subfolders, I would like to copy 3 of them, all starting with the same prefix (folderS-I-want in the previous command).

    With the fd --exact-depth 1 folderS-I-want I select everything I want to transfer, and with the sub-sequent --exec rclone copyto --progress {} <dest>:/remote-folder/ I launch the transfer of each… sequentially.

    So yes, it's less performant, but I think I have no choice at the moment, we can say to rclone to transfer what we point in the cli (which is the purpose of this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions