diff --git a/cmd/remove.go b/cmd/remove.go index e31191ede..0d28d4ab7 100644 --- a/cmd/remove.go +++ b/cmd/remove.go @@ -116,4 +116,6 @@ func init() { deleteCmd.PersistentFlags().BoolVar(&raw.dryrun, "dry-run", false, "Prints the path files that would be removed by the command. This flag does not trigger the removal of the files.") deleteCmd.PersistentFlags().StringVar(&raw.fromTo, "from-to", "", "Optionally specifies the source destination combination. For Example: BlobTrash, FileTrash, BlobFSTrash") deleteCmd.PersistentFlags().StringVar(&raw.permanentDeleteOption, "permanent-delete", "none", "This is a preview feature that PERMANENTLY deletes soft-deleted snapshots/versions. Possible values include 'snapshots', 'versions', 'snapshotsandversions', 'none'.") + deleteCmd.PersistentFlags().StringVar(&raw.includeBefore, common.IncludeBeforeFlagName, "", "Include only those files modified before or on the given date/time. The value should be in ISO8601 format. If no timezone is specified, the value is assumed to be in the local timezone of the machine running AzCopy. E.g. '2020-08-19T15:04:00Z' for a UTC time, or '2020-08-19' for midnight (00:00) in the local timezone. As of AzCopy 10.7, this flag applies only to files, not folders, so folder properties won't be copied when using this flag with --preserve-smb-info or --preserve-smb-permissions.") + deleteCmd.PersistentFlags().StringVar(&raw.includeAfter, common.IncludeAfterFlagName, "", "Include only those files modified on or after the given date/time. The value should be in ISO8601 format. If no timezone is specified, the value is assumed to be in the local timezone of the machine running AzCopy. E.g. '2020-08-19T15:04:00Z' for a UTC time, or '2020-08-19' for midnight (00:00) in the local timezone. As of AzCopy 10.5, this flag applies only to files, not folders, so folder properties won't be copied when using this flag with --preserve-smb-info or --preserve-smb-permissions.") } diff --git a/cmd/removeEnumerator.go b/cmd/removeEnumerator.go index c05fe1a4e..29505120c 100644 --- a/cmd/removeEnumerator.go +++ b/cmd/removeEnumerator.go @@ -66,6 +66,13 @@ func newRemoveEnumerator(cca *CookedCopyCmdArgs) (enumerator *CopyEnumerator, er filters := append(includeFilters, excludeFilters...) filters = append(filters, excludePathFilters...) filters = append(filters, includeSoftDelete...) + if cca.IncludeBefore != nil { + filters = append(filters, &IncludeBeforeDateFilter{Threshold: *cca.IncludeBefore}) + } + + if cca.IncludeAfter != nil { + filters = append(filters, &IncludeAfterDateFilter{Threshold: *cca.IncludeAfter}) + } // decide our folder transfer strategy // (Must enumerate folders when deleting from a folder-aware location. Can't do folder deletion just based on file