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{
Use: "delete remote:path",
Short: `Remove the contents of path.`,
Short: `Remove the files in path.`,
Long: `
Remove the files in path. Unlike ` + "`" + `purge` + "`" + ` it obeys include/exclude
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
` + "`" + `rclone purge` + "`" + `
the ` + "`purge`" + ` command.
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
Check what would be deleted first (use either)
For example, to delete all files bigger than 100MBytes, you may first want to check what
would be deleted (use either):
rclone --min-size 100M lsl 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

View file

@ -17,8 +17,9 @@ var commandDefinition = &cobra.Command{
Short: `Remove the path and all of its contents.`,
Long: `
Remove the path and all of its contents. Note that this does not obey
include/exclude filters - everything will be removed. Use ` + "`" + `delete` + "`" + ` if
you want to selectively delete files.
include/exclude filters - everything will be removed. Use the ` + "`delete`" + `
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
` + "`--dry-run` or the `--interactive`/`-i`" + ` flag.

View file

@ -14,10 +14,15 @@ func init() {
var commandDefinition = &cobra.Command{
Use: "rmdir remote:path",
Short: `Remove the path if empty.`,
Short: `Remove the empty directory at path.`,
Long: `
Remove the path. Note that you can't remove a path with
objects in it, use purge for that.`,
This removes empty directory given by path. Will not remove the path if it
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) {
cmd.CheckArgs(1, 1, command, args)
fdst := cmd.NewFsDir(args)

View file

@ -20,15 +20,21 @@ func init() {
var rmdirsCmd = &cobra.Command{
Use: "rmdirs remote:path",
Short: `Remove empty directories under the path.`,
Long: `This removes any empty directories (or directories that only contain
empty directories) under the path that it finds, including the path if
it has nothing in.
Long: `
This recursively removes any empty directories (including directories
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
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) {
cmd.CheckArgs(1, 1, command, args)