https://github.com/sammatzko/sorterylib
A fast, basic, cross-platform file-sorting library based on the Sortery command-line file sorter.
https://github.com/sammatzko/sorterylib
cross-platform file-sorting files rust rust-crate rust-library sorting
Last synced: about 2 months ago
JSON representation
A fast, basic, cross-platform file-sorting library based on the Sortery command-line file sorter.
- Host: GitHub
- URL: https://github.com/sammatzko/sorterylib
- Owner: SamMatzko
- License: mit
- Created: 2021-12-30T16:11:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-23T18:59:26.000Z (over 3 years ago)
- Last Synced: 2025-03-28T01:39:00.038Z (about 2 months ago)
- Topics: cross-platform, file-sorting, files, rust, rust-crate, rust-library, sorting
- Language: Rust
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT.txt
Awesome Lists containing this project
README
# SorteryLib
A fast, cross-platform file-sorting library based on the Sortery command-line file sorter. Along with fast sorting, SorteryLib comes with an easy-to-use `File` type, which is compatible with many other types, such as `String`, `str`, `std::path::Path`, `std::path::PathBuf`, and of course the `File` type itself.# Basic Usage
For more in-depth usage information, see the [SorteryLib Docs](https://docs.rs/sorterylib/latest/sorterylib/).
Here is a basic usage example:```rust
use sorterylib::prelude::*; // Import all the stuff needed for basic operationfn main() {
// The fields for initializing the Sorter struct
let source = File::new("/path/to/source/dir/");
let target = File::new("/path/to/target/dir/");
let date_format = String::from("%Y");
let date_type = String::from("m");
let preserve_name = true;
let exclude_type = vec![String::from("txt")];
let only_type = Vec::new();// Create the Sorter instance
let sorter = Sorter {
source: source.copy(), // The directory from which to get all the files to sort
target: target.copy(), // The directory to sort all the files into
date_format: date_format, // The date format to rename the files using.
date_type: date_type, // The date type to sort the files by
preserve_name: preserve_name, // Whether to include the old file name in the new name
exclude_type: exclude_type, // File type(s) to exclude
only_type: only_type // File type(s) to exclusively sort. Overrides `exclude_type`
};// Run the sorting algorithm
sorter.sort(false);
}
```