mirror of
https://github.com/rclone/rclone.git
synced 2025-08-11 06:34:15 +02:00
.circleci
.github
backend
bin
cmd
about
all
authorize
cachestats
cat
check
cleanup
cmount
config
copy
copyto
copyto.go
copyurl
cryptcheck
cryptdecode
dbhashsum
dedupe
delete
deletefile
genautocomplete
gendocs
hashsum
info
link
listremotes
ls
lsd
lsf
lsjson
lsl
md5sum
memtest
mkdir
mount
mountlib
move
moveto
ncdu
obscure
purge
rc
rcat
rcd
reveal
rmdir
rmdirs
serve
settier
sha1sum
size
sync
touch
tree
version
cmd.go
help.go
progress.go
progress_other.go
progress_windows.go
siginfo_darwin.go
siginfo_others.go
docs
fs
fstest
graphics
lib
vendor
vfs
.appveyor.yml
.gitignore
.golangci.yml
.pkgr.yml
.travis.yml
CONTRIBUTING.md
COPYING
MAINTAINERS.md
MANUAL.html
MANUAL.md
MANUAL.txt
Makefile
README.md
RELEASE.md
go.mod
go.sum
notes.txt
rclone.1
rclone.go
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package copyto
|
|
|
|
import (
|
|
"github.com/ncw/rclone/cmd"
|
|
"github.com/ncw/rclone/fs/operations"
|
|
"github.com/ncw/rclone/fs/sync"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
cmd.Root.AddCommand(commandDefintion)
|
|
}
|
|
|
|
var commandDefintion = &cobra.Command{
|
|
Use: "copyto source:path dest:path",
|
|
Short: `Copy files from source to dest, skipping already copied`,
|
|
Long: `
|
|
If source:path is a file or directory then it copies it to a file or
|
|
directory named dest:path.
|
|
|
|
This can be used to upload single files to other than their current
|
|
name. If the source is a directory then it acts exactly like the copy
|
|
command.
|
|
|
|
So
|
|
|
|
rclone copyto src dst
|
|
|
|
where src and dst are rclone paths, either remote:path or
|
|
/path/to/local or C:\windows\path\if\on\windows.
|
|
|
|
This will:
|
|
|
|
if src is file
|
|
copy it to dst, overwriting an existing file if it exists
|
|
if src is directory
|
|
copy it to dst, overwriting existing files if they exist
|
|
see copy command for full details
|
|
|
|
This doesn't transfer unchanged files, testing by size and
|
|
modification time or MD5SUM. It doesn't delete files from the
|
|
destination.
|
|
|
|
**Note**: Use the ` + "`-P`" + `/` + "`--progress`" + ` flag to view real-time transfer statistics
|
|
`,
|
|
Run: func(command *cobra.Command, args []string) {
|
|
cmd.CheckArgs(2, 2, command, args)
|
|
fsrc, srcFileName, fdst, dstFileName := cmd.NewFsSrcDstFiles(args)
|
|
cmd.Run(true, true, command, func() error {
|
|
if srcFileName == "" {
|
|
return sync.CopyDir(fdst, fsrc, false)
|
|
}
|
|
return operations.CopyFile(fdst, fsrc, dstFileName, srcFileName)
|
|
})
|
|
},
|
|
}
|