Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Add missing rmdirs command

Nick Craig-Wood8aae166a5b1b
diff --git a/cmd/rmdirs/rmdirs.go b/cmd/rmdirs/rmdirs.go
new file mode 100644
index 000000000..fbcb6d7dc
--- /dev/null
+++ b/cmd/rmdirs/rmdirs.go
@@ -0,0 +1,31 @@
+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",
+ Short: `Remove any empty directoryies 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.
+
+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)
+ cmd.Run(true, command, func() error {
+ return fs.Rmdirs(fdst)
+ })
+ },
+}