Skip to content

Instantly share code, notes, and snippets.

View rbordeanu's full-sized avatar

Răzvan Bordeanu rbordeanu

  • Bucharest
  • 05:25 (UTC +03:00)
View GitHub Profile
@rbordeanu
rbordeanu / rename.js
Created March 16, 2020 13:46 — forked from scriptex/rename.js
Rename all files in a folder with NodeJS
const { join } = require('path');
const { readdirSync, renameSync } = require('fs');
const [dir, search, replace] = process.argv.slice(2);
const match = RegExp(search, 'g');
const files = readdirSync(dir);
files
.filter(file => file.match(match))
.forEach(file => {
const filePath = join(dir, file);