Crates.io | file-matcher |
lib.rs | file-matcher |
version | 0.7.0 |
source | src |
created_at | 2021-07-16 19:28:43.385828 |
updated_at | 2021-10-12 20:23:32.203429 |
description | A library to search files and folders based on the name pattern (regex, wildmatch, exact) |
homepage | https://github.com/feenkcom/file-matcher-rs |
repository | https://github.com/feenkcom/file-matcher-rs |
max_upload_size | |
id | 423767 |
size | 49,988 |
A Rust library to search files and folders based on the name pattern (regex, wildcard, exact).
regex
- adds regex support using Regex cratewildmatch
- adds a wildcard matching using Wildmatch cratecopier
- allows users to copy declared files and folders, uses fs_extra cratemover
- allows users to move declared files and folders, uses fs_extra crateserde
- allows users to serialize / deserialize declared file and folder filters, uses serdeUse FileNamed
to search for exactly one file matching the name pattern. Returns an Error
if none or more than one file was found.
FileNamed::regex("cat.*")
.within("tests/assets")
.find()?
Use FolderNamed
to search for exactly one folder matching the name pattern. Returns an Error
if none or more than one folder was found.
FolderNamed::wildmatch("cat*")
.within("tests/assets")
.find()?
Check if a file exists:
FileNamed::wildmatch("cat*")
.within("tests/assets")
.exists()?
Check if a folder exists:
FolderNamed::wildmatch("cat*")
.within("tests/assets")
.exists()?
Find and copy a file matching a name pattern to destination
folder under the same name:
FileNamed::wildmatch("cat*")
.within("tests/assets")
.copy("destination")?
Find and copy a file matching a name pattern to destination
folder as kitty.txt
:
FileNamed::wildmatch("cat*")
.within("tests/assets")
.copy(Path::new("destination").join("kitty.txt"))?
Alternatively, assign an alias for copy/move operations.
The following will find a file matching a given pattern name and will copy it into the destination
folder under the kitty.txt
name:
FileNamed::wildmatch("cat*")
.alias("kitty.txt")
.within("tests/assets")
.copy("destination")?