Get List of all files in a directory in Node.js
const testFolder = './tests/';
const fs = require('fs');
fs.readdir(testFolder, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
Get List of all files in a directory in Node.js
const testFolder = './tests/';
const fs = require('fs');
fs.readdir(testFolder, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
dir list all files in subdirectories
dir *.txt *.doc # filter by extension (both doc and txt)
dir /a:-d # files only (no subfolders)
dir /s # current directory and subfolders content
dir /s /a:-d # files only (including subfolders)
dir > myfile.txt # stored in myfile.txt (dir /s > myfile.txt with subfolders)
dir /o:[sortorder] # example: dir /o:-s (sort by decreasing size)
N : By name (alphabetic).
S : By size (smallest first).
E : By extension (alphabetic).
D : By date/time (oldest first).
- : Prefix to reverse order.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us