Skip to content

Instantly share code, notes, and snippets.

@premkash
Created July 13, 2020 14:13
Show Gist options
  • Save premkash/afd85e70d3f969a088d71ac676c624b5 to your computer and use it in GitHub Desktop.
Save premkash/afd85e70d3f969a088d71ac676c624b5 to your computer and use it in GitHub Desktop.
Displays the info about files in a directory at a given path
const fsp = require("fs/promises");
async function dirFilesInfo(path) {
const dir = await fsp.opendir(path);
for await (const dirEntry of dir) {
const fileInfo = await fsp.stat("./" + dirEntry.name);
console.log(dirEntry.name, fileInfo);
}
}
dirFilesInfo("./").catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment