#filenames #sanitizer #filename

bin+lib sanitize-filename-reader-friendly

A filename sanitizer aiming to produce reader friendly filenames

13 releases (stable)

Uses new Rust 2024

new 2.3.1 Apr 6, 2026
2.3.0 May 6, 2025
2.2.1 Nov 16, 2021
2.1.0 May 9, 2021
0.9.2 Mar 21, 2020

#510 in Parser implementations

Download history 329/week @ 2025-12-20 89/week @ 2025-12-27 298/week @ 2026-01-03 813/week @ 2026-01-10 529/week @ 2026-01-17 279/week @ 2026-01-24 431/week @ 2026-01-31 569/week @ 2026-02-07 1848/week @ 2026-02-14 1255/week @ 2026-02-21 1687/week @ 2026-02-28 2573/week @ 2026-03-07 1339/week @ 2026-03-14 840/week @ 2026-03-21 1190/week @ 2026-03-28 1158/week @ 2026-04-04

4,796 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

16KB
227 lines

sanitize-filename-reader-friendly

A filename sanitizer aiming to produce reader friendly filenames, while preserving as much information as possible.

Cargo Documentation License

Unlike Node's sanitize-filename, this library replaces non-file-system-compatible characters with underscore and space. Both are trimmed when they appear at the beginning or at the end of a line or when they repeat within. Non-printable punctuation marks are replaced by underscores, other non-printable characters by spaces, except the non-printable space U+200b which is filtered out. Newlines are replaced by dashes.

Sample usage:

extern crate sanitize_filename_reader_friendly;
use crate::sanitize_filename_reader_friendly::sanitize;

fn main() {
    println!("{}",
        sanitize("Read: http://blog.getreu.net/projects/tp-note/"));
    // Prints: "Read_ http_blog.getreu.net_projects_tp-note"
}

This library comes with a simple command-line application. Usage:

cargo install sanitize-filename-reader-friendly
sanitize-filename <input.txt >output.txt

Dependencies

~510KB