Skip to content

Instantly share code, notes, and snippets.

@jumoog
Created March 8, 2024 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jumoog/ecbfc913cc2d5033597c20357d6532da to your computer and use it in GitHub Desktop.
Save jumoog/ecbfc913cc2d5033597c20357d6532da to your computer and use it in GitHub Desktop.
rclone move srcPath destPath --ignore-checksum --delete-empty-src-dirs --ignore-existing --quiet
package main
import (
"context"
// add the backend that you need
_ "github.com/rclone/rclone/backend/local"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/sync"
)
// same function like
// rclone move srcPath destPath --ignore-checksum --delete-empty-src-dirs --ignore-existing --quiet
func (app *application) rclone(src, dst string) error {
ctx := context.Background()
ctx, ci := fs.AddConfig(ctx)
ci.IgnoreExisting = true
ci.IgnoreChecksum = true
fsrc, srcFileName, fdst := cmd.NewFsSrcFileDst([]string{src, dst})
if srcFileName == "" {
// Perform the move operation
return sync.MoveDir(ctx, fdst, fsrc, true, false)
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment