photo_sort 0.3.3

A tool to rename and sort photos/videos by its EXIF date/metadata. It tries to extract the date from the EXIF data or file name and renames the image file according to a given format string. Foreach source directory all images are processed and renamed to the target directory
Documentation
use crate::analysis::name_formatters::{NameFormatter, NameFormatterInvocationInfo};
use anyhow::Result;
use regex::Regex;
use std::sync::LazyLock;

static NAME_FORMAT: LazyLock<regex::Regex> =
    LazyLock::new(|| regex::Regex::new(r"^(name|n)$").expect("Failed to compile regex"));

/// Formats a name format command {name} to a name string.
#[derive(Debug, Default)]
pub struct FormatName {}

impl NameFormatter for FormatName {
    fn argument_template(&self) -> &Regex {
        &NAME_FORMAT
    }
    fn replacement_text(
        &self,
        _capture: regex::Captures<'_>,
        invocation_info: &NameFormatterInvocationInfo,
    ) -> Result<String> {
        Ok(invocation_info.cleaned_name.clone())
    }
}