Skip to content

Instantly share code, notes, and snippets.

@rlpt
rlpt / gist:e5b1615d116b14526d6ee149bbab33d9
Created February 16, 2025 09:04
nodejs script to rename files to kebab-case
const fs = require("fs");
const path = require("path");
function toKebabCase(name) {
// Split at first period to separate initial name from the rest
const [firstPart, ...rest] = name.split(".");
// Convert camelCase and PascalCase to space-separated for first part only
const withSpaces = firstPart
.replace(/([a-z])([A-Z])/g, "$1 $2")