Plugin for nnn file manager, to only delete files from the last-selected directory. Written in Hare ("harelang").




  

use fs;
use os;
use path;
use regex;

fn walk(buf: *path::buffer) void = {
  let iter = os::iter(path::string(buf))!;
  defer fs::finish(iter);
  for (const d => fs::next(iter)!) {
    if (d.name == "." || d.name == "..") {
      continue;
    };
    path::push(buf, d.name)!;
    let filename = path::string(buf);
    const re = regex::compile(` `)!;
    if (regex::test(&re, filename)) {
        const result = regex::replace(&re, filename, `_`)!;
        os::move(filename, result)!;
    };

    path::pop(buf);
  };
};

export fn main() void = {
  const root = if (len(os::args) <= 1) "." else os::args[1];
  let buf = path::init(root)!;
  walk(&buf);
};


  






This site uses the httpd webserver running on the openbsd operating system.
Website content copyright Brett Mahar