2016-11-27 19:36:13 +01:00
|
|
|
package rmdir
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ncw/rclone/cmd"
|
|
|
|
"github.com/ncw/rclone/fs"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmd.Root.AddCommand(rmdirsCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var rmdirsCmd = &cobra.Command{
|
|
|
|
Use: "rmdirs remote:path",
|
2017-07-21 19:17:57 +02:00
|
|
|
Short: `Remove empty directories under the path.`,
|
2016-11-27 19:36:13 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
This is useful for tidying up remotes that rclone has left a lot of
|
|
|
|
empty directories in.
|
|
|
|
|
|
|
|
`,
|
|
|
|
Run: func(command *cobra.Command, args []string) {
|
|
|
|
cmd.CheckArgs(1, 1, command, args)
|
|
|
|
fdst := cmd.NewFsDst(args)
|
2016-12-04 17:52:24 +01:00
|
|
|
cmd.Run(true, false, command, func() error {
|
2017-02-01 14:23:31 +01:00
|
|
|
return fs.Rmdirs(fdst, "")
|
2016-11-27 19:36:13 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|