📅  最后修改于: 2022-03-11 14:59:50.403000             🧑  作者: Mango
var fs = require('fs');
var files = fs.readdirSync('/path/to/dir/')
/* now files is an Array of the name of the files in the folder and you can pick a random name inside of that array */
let chosenFile = files[Math.floor(Math.random() * files.length)]