2016-08-05 18:12:27 +02:00
|
|
|
package delete
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ncw/rclone/cmd"
|
|
|
|
"github.com/ncw/rclone/fs"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2016-10-22 13:05:45 +02:00
|
|
|
cmd.Root.AddCommand(commandDefintion)
|
2016-08-05 18:12:27 +02:00
|
|
|
}
|
|
|
|
|
2016-10-22 13:05:45 +02:00
|
|
|
var commandDefintion = &cobra.Command{
|
2016-08-05 18:12:27 +02:00
|
|
|
Use: "delete remote:path",
|
|
|
|
Short: `Remove the contents of path.`,
|
|
|
|
Long: `
|
|
|
|
Remove the contents of path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude
|
|
|
|
filters so can be used to selectively delete files.
|
|
|
|
|
|
|
|
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)
|
|
|
|
cmd.Run(true, command, func() error {
|
|
|
|
return fs.Delete(fsrc)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|