mirror of
https://github.com/rclone/rclone.git
synced 2025-01-24 12:56:36 +02:00
Make dedupe take an optional mode parameter
This commit is contained in:
parent
520ded60e3
commit
38adb35abe
@ -283,6 +283,10 @@ For example to rename all the identically named photos in your Google Photos dir
|
|||||||
|
|
||||||
rclone dedupe --dedupe-mode rename "drive:Google Photos"
|
rclone dedupe --dedupe-mode rename "drive:Google Photos"
|
||||||
|
|
||||||
|
The modes can also be passed as an extra parameter, eg
|
||||||
|
|
||||||
|
rclone dedupe rename "drive:Google Photos"
|
||||||
|
|
||||||
### rclone config ###
|
### rclone config ###
|
||||||
|
|
||||||
Enter an interactive configuration session.
|
Enter an interactive configuration session.
|
||||||
|
25
rclone.go
25
rclone.go
@ -438,15 +438,32 @@ don't match. It doesn't alter the source or destination.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dedupeCmd = &cobra.Command{
|
var dedupeCmd = &cobra.Command{
|
||||||
Use: "dedupe remote:path",
|
Use: "dedupe [mode] remote:path",
|
||||||
Short: `Interactively find duplicate files delete/rename them.`,
|
Short: `Interactively find duplicate files delete/rename them.`,
|
||||||
Long: `
|
Long: `
|
||||||
Interactively find duplicate files and offer to delete all
|
Interactively find duplicate files and offer to delete all
|
||||||
but one or rename them to be different. Only useful with
|
but one or rename them to be different. Only useful with
|
||||||
Google Drive which can have duplicate file names.`,
|
Google Drive which can have duplicate file names.
|
||||||
|
|
||||||
|
Pass in an extra parameter to make the dedupe noninteractive
|
||||||
|
|
||||||
|
interactive - interactive as above.
|
||||||
|
skip - removes identical files then skips anything left.
|
||||||
|
first - removes identical files then keeps the first one.
|
||||||
|
newest - removes identical files then keeps the newest one.
|
||||||
|
oldest - removes identical files then keeps the oldest one.
|
||||||
|
rename - removes identical files then renames the rest to be different.
|
||||||
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
checkArgs(1, 1, cmd, args)
|
checkArgs(1, 2, cmd, args)
|
||||||
fdst := NewFsSrc(args[1])
|
if len(args) > 1 {
|
||||||
|
err := dedupeMode.Set(args[0])
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
args = args[1:]
|
||||||
|
}
|
||||||
|
fdst := newFsSrc(args)
|
||||||
run(false, cmd, func() error {
|
run(false, cmd, func() error {
|
||||||
return fs.Deduplicate(fdst, dedupeMode)
|
return fs.Deduplicate(fdst, dedupeMode)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user