docs: update documentation of commands delete,purge,rmdir,rmdirs

This commit is contained in:
albertony 2020-11-13 11:07:34 +01:00 committed by Nick Craig-Wood
parent fb001b6c01
commit 79474b2e4c
4 changed files with 30 additions and 17 deletions

View File

@ -21,25 +21,26 @@ func init() {
var commandDefinition = &cobra.Command{ var commandDefinition = &cobra.Command{
Use: "delete remote:path", Use: "delete remote:path",
Short: `Remove the contents of path.`, Short: `Remove the files in path.`,
Long: ` Long: `
Remove the files in path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude Remove the files in path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude
filters so can be used to selectively delete files. filters so can be used to selectively delete files.
` + "`" + `rclone delete` + "`" + ` only deletes objects but leaves the directory structure ` + "`rclone delete`" + ` only deletes files but leaves the directory structure
alone. If you want to delete a directory and all of its contents use alone. If you want to delete a directory and all of its contents use
` + "`" + `rclone purge` + "`" + ` the ` + "`purge`" + ` command.
If you supply the --rmdirs flag, it will remove all empty directories along with it. If you supply the --rmdirs flag, it will remove all empty directories along with it.
You can also use the separate command ` + "`rmdir`" + ` or ` + "`rmdirs`" + ` to
delete empty directories only.
Eg delete all files bigger than 100MBytes For example, to delete all files bigger than 100MBytes, you may first want to check what
would be deleted (use either):
Check what would be deleted first (use either)
rclone --min-size 100M lsl remote:path rclone --min-size 100M lsl remote:path
rclone --dry-run --min-size 100M delete remote:path rclone --dry-run --min-size 100M delete remote:path
Then delete Then proceed with the actual delete:
rclone --min-size 100M delete remote:path rclone --min-size 100M delete remote:path

View File

@ -17,8 +17,9 @@ var commandDefinition = &cobra.Command{
Short: `Remove the path and all of its contents.`, Short: `Remove the path and all of its contents.`,
Long: ` Long: `
Remove the path and all of its contents. Note that this does not obey Remove the path and all of its contents. Note that this does not obey
include/exclude filters - everything will be removed. Use ` + "`" + `delete` + "`" + ` if include/exclude filters - everything will be removed. Use the ` + "`delete`" + `
you want to selectively delete files. command if you want to selectively delete files. To delete empty directories only,
use command ` + "`rmdir`" + ` or ` + "`rmdirs`" + `.
**Important**: Since this can cause data loss, test first with the **Important**: Since this can cause data loss, test first with the
` + "`--dry-run` or the `--interactive`/`-i`" + ` flag. ` + "`--dry-run` or the `--interactive`/`-i`" + ` flag.

View File

@ -14,10 +14,15 @@ func init() {
var commandDefinition = &cobra.Command{ var commandDefinition = &cobra.Command{
Use: "rmdir remote:path", Use: "rmdir remote:path",
Short: `Remove the path if empty.`, Short: `Remove the empty directory at path.`,
Long: ` Long: `
Remove the path. Note that you can't remove a path with This removes empty directory given by path. Will not remove the path if it
objects in it, use purge for that.`, has any objects in it, not even empty subdirectories. Use
command ` + "`rmdirs`" + ` (or ` + "`delete`" + ` with option ` + "`--rmdirs`" + `)
to do that.
To delete a path and any objects in it, use ` + "`purge`" + ` command.
`,
Run: func(command *cobra.Command, args []string) { Run: func(command *cobra.Command, args []string) {
cmd.CheckArgs(1, 1, command, args) cmd.CheckArgs(1, 1, command, args)
fdst := cmd.NewFsDir(args) fdst := cmd.NewFsDir(args)

View File

@ -20,15 +20,21 @@ func init() {
var rmdirsCmd = &cobra.Command{ var rmdirsCmd = &cobra.Command{
Use: "rmdirs remote:path", Use: "rmdirs remote:path",
Short: `Remove empty directories under the path.`, Short: `Remove empty directories under the path.`,
Long: `This removes any empty directories (or directories that only contain Long: `
empty directories) under the path that it finds, including the path if This recursively removes any empty directories (including directories
it has nothing in. that only contain empty directories), that it finds under the path.
The root path itself will also be removed if it is empty, unless
you supply the ` + "`--leave-root`" + ` flag.
If you supply the --leave-root flag, it will not remove the root directory. Use command ` + "`rmdir`" + ` to delete just the empty directory
given by path, not recurse.
This is useful for tidying up remotes that rclone has left a lot of This is useful for tidying up remotes that rclone has left a lot of
empty directories in. empty directories in. For example the ` + "`delete`" + ` command will
delete files but leave the directory structure (unless used with
option ` + "`--rmdirs`" + `).
To delete a path and any objects in it, use ` + "`purge`" + ` command.
`, `,
Run: func(command *cobra.Command, args []string) { Run: func(command *cobra.Command, args []string) {
cmd.CheckArgs(1, 1, command, args) cmd.CheckArgs(1, 1, command, args)