"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
delete: added --rmdirs flag to delete directories as well - fixes #4055
Kushf555873f1878
diff --git a/cmd/delete/delete.go b/cmd/delete/delete.goindex 0e9f5b3da..bf3c0fa81 100644--- a/cmd/delete/delete.go+++ b/cmd/delete/delete.go@@ -4,12 +4,19 @@ import ("context""github.com/rclone/rclone/cmd"+ "github.com/rclone/rclone/fs/config/flags""github.com/rclone/rclone/fs/operations""github.com/spf13/cobra")+var (+ rmdirs = false+)+func init() {cmd.Root.AddCommand(commandDefinition)+ cmdFlags := commandDefinition.Flags()+ flags.BoolVarP(cmdFlags, &rmdirs, "rmdirs", "", rmdirs, "rmdirs removes empty directories but leaves root intact")}var commandDefinition = &cobra.Command{@@ -23,6 +30,8 @@ filters so can be used to selectively delete files.alone. If you want to delete a directory and all of its contents use` + "`" + `rclone purge` + "`" + `+If you supply the --rmdirs flag, it will remove all empty directories along with it.+Eg delete all files bigger than 100MBytesCheck what would be deleted first (use either)@@ -41,7 +50,14 @@ delete all files bigger than 100MBytes.cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)cmd.Run(true, false, command, func() error {- return operations.Delete(context.Background(), fsrc)+ if err := operations.Delete(context.Background(), fsrc); err != nil {+ return err+ }+ if rmdirs {+ fdst := cmd.NewFsDir(args)+ return operations.Rmdirs(context.Background(), fdst, "", true)+ }+ return nil})},}