Crate nflz

source · []
Expand description

NFLZ (library)

Library to add leading zeros to ascending numbered file names. NFLZ stands for Numbered Files Leading Zeros.

This library helps you to manage files inside your file system that belong to a set of ordered files. An example are photos from a camera.

NFLZAssistant is the main entry point into the library. Please check examples inside the README or the repository.

What it Does

Content of some directory: On the left you see files that are inside a directory. The files may represent photos from one or multiple cameras that you organized for example with Windows Explorer. nflz can add an appropriate number of leading zeroes into the filename so that every trivial program can sort them correctly by their apathetically order. In short: It ensures that chronological order equals the alphabetical order.

paris (1).png   =>  paris (01).png
paris (2).png   =>  paris (02).png
...
paris (12).png  =>  paris (12).png
...
paris (n).png   =>  n digits => indicator for how many zeros to add

Code Example

use nflz::NFLZAssistant;

/// Minimal example that renames all files in the given directory.
/// After the operation is done, all will include the same amount of digits
/// inside their number group inside the filename.
fn main() {
    let assistant = NFLZAssistant::new("./test-resources").unwrap();
    dbg!(assistant.files_to_rename());
    // some files may already have the correct name
    dbg!(assistant.files_without_rename());
    if assistant.check_can_rename_all().is_ok() {
        assistant.rename_all().unwrap();
    }
}

Library Design

Structs

Main entry point into the library. Helper struct that guides a user through the whole process of the library.

Enums

Main error of the library.