add bins and alternatives

This commit is contained in:
JOLIMAITRE Matthieu 2024-06-18 03:52:40 +02:00
parent a935bb9893
commit 9f3594e0d3
21 changed files with 210 additions and 10 deletions

View file

@ -0,0 +1,17 @@
#!/bin/env -S deno run -A
import { basename, dirname } from "https://deno.land/std@0.187.0/path/mod.ts";
const files = Deno.args;
function rand_int(ceil = 1000) {
return Math.floor(Math.random() * ceil);
}
const keyed = files.map((name) => ({ key: rand_int(files.length), name }));
keyed.sort(({ key: a }, { key: b }) => (a - b));
await Promise.all(keyed.map(({ name }, index) => {
const dir = dirname(name);
const base = basename(name);
return Deno.rename(`${dir}/${base}`, `${dir}/${index}_${base}`);
}));