Expand description
SorteryLib is a fast, cross-platform file-sorting library based on the Sortery command-line file sorter.
Basic usage example:
use sorterylib::prelude::*; // Import all the stuff needed for basic operation
fn 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 (uncomment line below)
// sorter.sort(false);
}
You can find more detailed descriptions of the fields on the Sorter
page.
Modules§
- prelude
- Includes all the stuff needed for basic operations, in one neat module.
- structs
- Commonly-used structs.
Structs§
- Sorter
- The sorter struct that sorts the files. There are two ways to create an instance
of
Sorter
: passing the individual fields, and usingSorter::from_json
.