2016-08-06 00:12:27 +08:00
|
|
|
package delete
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ncw/rclone/cmd"
|
2018-01-13 00:30:54 +08:00
|
|
|
"github.com/ncw/rclone/fs/operations"
|
2016-08-06 00:12:27 +08:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2016-10-22 19:05:45 +08:00
|
|
|
cmd.Root.AddCommand(commandDefintion)
|
2016-08-06 00:12:27 +08:00
|
|
|
}
|
|
|
|
|
2016-10-22 19:05:45 +08:00
|
|
|
var commandDefintion = &cobra.Command{
|
2016-08-06 00:12:27 +08:00
|
|
|
Use: "delete remote:path",
|
|
|
|
Short: `Remove the contents of path.`,
|
|
|
|
Long: `
|
2018-11-03 01:07:45 +08:00
|
|
|
Remove the files in path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude
|
2016-08-06 00:12:27 +08:00
|
|
|
filters so can be used to selectively delete files.
|
|
|
|
|
2018-11-03 01:07:45 +08:00
|
|
|
` + "`" + `rclone delete` + "`" + ` only deletes objects but leaves the directory structure
|
|
|
|
alone. If you want to delete a directory and all of its contents use
|
|
|
|
` + "`" + `rclone purge` + "`" + `
|
|
|
|
|
2016-08-06 00:12:27 +08:00
|
|
|
Eg delete all files bigger than 100MBytes
|
|
|
|
|
|
|
|
Check what would be deleted first (use either)
|
|
|
|
|
|
|
|
rclone --min-size 100M lsl remote:path
|
|
|
|
rclone --dry-run --min-size 100M delete remote:path
|
|
|
|
|
|
|
|
Then delete
|
|
|
|
|
|
|
|
rclone --min-size 100M delete remote:path
|
|
|
|
|
|
|
|
That reads "delete everything with a minimum size of 100 MB", hence
|
|
|
|
delete all files bigger than 100MBytes.
|
|
|
|
`,
|
|
|
|
Run: func(command *cobra.Command, args []string) {
|
|
|
|
cmd.CheckArgs(1, 1, command, args)
|
|
|
|
fsrc := cmd.NewFsSrc(args)
|
2016-12-05 00:52:24 +08:00
|
|
|
cmd.Run(true, false, command, func() error {
|
2018-01-13 00:30:54 +08:00
|
|
|
return operations.Delete(fsrc)
|
2016-08-06 00:12:27 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|