github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/cmd/delete/delete.go (about) 1 package delete 2 3 import ( 4 "context" 5 6 "github.com/ncw/rclone/cmd" 7 "github.com/ncw/rclone/fs/operations" 8 "github.com/spf13/cobra" 9 ) 10 11 func init() { 12 cmd.Root.AddCommand(commandDefintion) 13 } 14 15 var commandDefintion = &cobra.Command{ 16 Use: "delete remote:path", 17 Short: `Remove the contents of path.`, 18 Long: ` 19 Remove the files in path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude 20 filters so can be used to selectively delete files. 21 22 ` + "`" + `rclone delete` + "`" + ` only deletes objects but leaves the directory structure 23 alone. If you want to delete a directory and all of its contents use 24 ` + "`" + `rclone purge` + "`" + ` 25 26 Eg delete all files bigger than 100MBytes 27 28 Check what would be deleted first (use either) 29 30 rclone --min-size 100M lsl remote:path 31 rclone --dry-run --min-size 100M delete remote:path 32 33 Then delete 34 35 rclone --min-size 100M delete remote:path 36 37 That reads "delete everything with a minimum size of 100 MB", hence 38 delete all files bigger than 100MBytes. 39 `, 40 Run: func(command *cobra.Command, args []string) { 41 cmd.CheckArgs(1, 1, command, args) 42 fsrc := cmd.NewFsSrc(args) 43 cmd.Run(true, false, command, func() error { 44 return operations.Delete(context.Background(), fsrc) 45 }) 46 }, 47 }