I am using nodejs.
Hi, I need to delete all files starting with a word in a folder.
I have tried the next code but no look:
const deleteFile = (path, regex) => {
fs.readdirSync(path)
.filter(f => regex.test(f))
.map(f => fs.unlinkSync(path + f));
};
const starting_filename="name_to_delete";
if (tenantInstance.companyLogoUrl) {
const path = join(__dirname, "..", "..", "..", "public");
const regex = `/^${starting_filename}+/`;
deleteFile(path, new RegExp(regex));
}