GithubHelp home page GithubHelp logo

sammatzko / sorterylib Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 43 KB

A fast, basic, cross-platform file-sorting library based on the Sortery command-line file sorter.

License: MIT License

Rust 100.00%
rust rust-library rust-crate files sorting file-sorting cross-platform

sorterylib's Introduction

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. Here is a 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
    sorter.sort(false);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.