2022-08-28 11:21:57 +00:00
|
|
|
// Package rmdir provides the rmdir command.
|
2016-08-05 16:12:27 +00:00
|
|
|
package rmdir
|
|
|
|
|
|
|
|
import (
|
2019-06-17 08:34:30 +00:00
|
|
|
"context"
|
|
|
|
|
2019-07-28 17:47:38 +00:00
|
|
|
"github.com/rclone/rclone/cmd"
|
|
|
|
"github.com/rclone/rclone/fs/operations"
|
2016-08-05 16:12:27 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-10-11 15:58:11 +00:00
|
|
|
cmd.Root.AddCommand(commandDefinition)
|
2016-08-05 16:12:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-11 15:58:11 +00:00
|
|
|
var commandDefinition = &cobra.Command{
|
2016-08-05 16:12:27 +00:00
|
|
|
Use: "rmdir remote:path",
|
2020-11-13 10:07:34 +00:00
|
|
|
Short: `Remove the empty directory at path.`,
|
2016-08-05 16:12:27 +00:00
|
|
|
Long: `
|
2020-11-13 10:07:34 +00:00
|
|
|
This removes empty directory given by path. Will not remove the path if it
|
|
|
|
has any objects in it, not even empty subdirectories. Use
|
2022-06-19 13:51:37 +00:00
|
|
|
command [rmdirs](/commands/rclone_rmdirs/) (or [delete](/commands/rclone_delete/)
|
|
|
|
with option ` + "`--rmdirs`" + `) to do that.
|
2020-11-13 10:07:34 +00:00
|
|
|
|
2022-06-19 13:51:37 +00:00
|
|
|
To delete a path and any objects in it, use [purge](/commands/rclone_purge/) command.
|
2020-11-13 10:07:34 +00:00
|
|
|
`,
|
2016-08-05 16:12:27 +00:00
|
|
|
Run: func(command *cobra.Command, args []string) {
|
|
|
|
cmd.CheckArgs(1, 1, command, args)
|
2018-05-07 16:58:16 +00:00
|
|
|
fdst := cmd.NewFsDir(args)
|
2016-12-04 16:52:24 +00:00
|
|
|
cmd.Run(true, false, command, func() error {
|
2019-06-17 08:34:30 +00:00
|
|
|
return operations.Rmdir(context.Background(), fdst, "")
|
2016-08-05 16:12:27 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|