Skip to main content

How to bulk rename files

You can use the storage manager to make a script to organize your files:

import { Storage } from 'typefs';

async function bulkRename() {
const contents = await Storage.disk('assets').listContents('/');
// Filter jpeg images
const jpegs = contents.filter((f) => f.endsWith('.jpg'))
const now = Date.now();

// add time stamp to jpeg images
jpegs.forEach(async (fileName) => {
const newFileName = f.replace('.jpg', `-${now}.jpg`);
await Storage.disk('assets').move(fileName, newFileName);
})
}