mirror of
https://github.com/rclone/rclone.git
synced 2025-06-04 19:24:35 +08:00
move: add --delete-empty-src-dirs flag - fixes #1854
This commit is contained in:
@ -6,8 +6,14 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Globals
|
||||
var (
|
||||
deleteEmptySrcDirs = false
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd.Root.AddCommand(commandDefintion)
|
||||
commandDefintion.Flags().BoolVarP(&deleteEmptySrcDirs, "delete-empty-src-dirs", "", deleteEmptySrcDirs, "Delete empty source dirs after move")
|
||||
}
|
||||
|
||||
var commandDefintion = &cobra.Command{
|
||||
@ -28,6 +34,8 @@ move will be used, otherwise it will copy it (server side if possible)
|
||||
into ` + "`dest:path`" + ` then delete the original (if no errors on copy) in
|
||||
` + "`source:path`" + `.
|
||||
|
||||
If you want to delete empty source directories after move, use the --delete-empty-src-dirs flag.
|
||||
|
||||
**Important**: Since this can cause data loss, test first with the
|
||||
--dry-run flag.
|
||||
`,
|
||||
@ -35,7 +43,8 @@ into ` + "`dest:path`" + ` then delete the original (if no errors on copy) in
|
||||
cmd.CheckArgs(2, 2, command, args)
|
||||
fsrc, fdst := cmd.NewFsSrcDst(args)
|
||||
cmd.Run(true, true, command, func() error {
|
||||
return fs.MoveDir(fdst, fsrc)
|
||||
|
||||
return fs.MoveDir(fdst, fsrc, deleteEmptySrcDirs)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user