1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-04 09:33:36 +00:00

filter: add metadata filters --metadata-include/exclude/filter and friends

Fixes #6353
This commit is contained in:
Nick Craig-Wood
2022-08-04 18:19:05 +01:00
parent 4a31961c4f
commit 3a6f1f5cd7
7 changed files with 173 additions and 13 deletions

View File

@@ -2355,6 +2355,12 @@ For the filtering options
* `--min-age`
* `--max-age`
* `--dump filters`
* `--metadata-include`
* `--metadata-include-from`
* `--metadata-exclude`
* `--metadata-exclude-from`
* `--metadata-filter`
* `--metadata-filter-from`
See the [filtering section](/filtering/).

View File

@@ -32,7 +32,7 @@ you expect. Instead use a `--filter...` flag.
## Patterns for matching path/file names
### Pattern syntax
### Pattern syntax {#patterns}
Here is a formal definition of the pattern syntax,
[examples](#examples) are below.
@@ -194,7 +194,7 @@ them into regular expressions.
| Rooted Regexp | `/{{.*\.jpe?g}}` | `/file.jpeg` | `/file.png` |
| | | `/file.jpg` | `/dir/file.jpg` |
## How filter rules are applied to files
## How filter rules are applied to files {#how-filter-rules-work}
Rclone path/file name filters are made up of one or more of the following flags:
@@ -757,6 +757,43 @@ E.g. for the following directory structure:
The command `rclone ls --exclude-if-present .ignore dir1` does
not list `dir3`, `file3` or `.ignore`.
## Metadata filters {#metadata}
The metadata filters work in a very similar way to the normal file
name filters, except they match [metadata](/docs/#metadata) on the
object.
The metadata should be specified as `key=value` patterns. This may be
wildcarded using the normal [filter patterns](#patterns) or [regular
expressions](#regexp).
For example if you wished to list only local files with a mode of
`100664` you could do that with:
rclone lsf -M --files-only --metadata-include "mode=100664" .
Or if you wished to show files with an `atime`, `mtime` or `btime` at a given date:
rclone lsf -M --files-only --metadata-include "[abm]time=2022-12-16*" .
Like file filtering, metadata filtering only applies to files not to
directories.
The filters can be applied using these flags.
- `--metadata-include` - Include metadatas matching pattern
- `--metadata-include-from` - Read metadata include patterns from file (use - to read from stdin)
- `--metadata-exclude` - Exclude metadatas matching pattern
- `--metadata-exclude-from` - Read metadata exclude patterns from file (use - to read from stdin)
- `--metadata-filter` - Add a metadata filtering rule
- `--metadata-filter-from` - Read metadata filtering patterns from a file (use - to read from stdin)
Each flag can be repeated. See the section on [how filter rules are
applied](#how-filter-rules-work) for more details - these flags work
in an identical way to the file name filtering flags, but instead of
file name patterns have metadata patterns.
## Common pitfalls
The most frequent filter support issues on

View File

@@ -66,6 +66,22 @@ It can be triggered when you did a server-side copy.
Reading metadata will also provide custom (non-standard nor reserved) ones.
## Filtering auto generated files
The Internet Archive automatically creates metadata files after
upload. These can cause problems when doing an `rclone sync` as rclone
will try, and fail, to delete them. These metadata files are not
changeable, as they are created by the Internet Archive automatically.
These auto-created files can be excluded from the sync using [metadata
filtering](/filtering/#metadata).
rclone sync ... --metadata-exclude "source=metadata" --metadata-exclude "format=Metadata"
Which excludes from the sync any files which have the
`source=metadata` or `format=Metadata` flags which are added to
Internet Archive auto-created files.
## Configuration
Here is an example of making an internetarchive configuration.