I have a fodler on my local machine and I would like to pick a random file from it. I have tried using this :
var files = fs.readdirSync(`/Users/...`)
random_file = files[Math.floor(Math.random() * files.length)]
But sometimes I get this as random-file : .DS_Store
Could anyone help me fix this please
Just run a filter and return filenames !== Ds Store
files=files.filter(fileName=>fileName!==".DS_Store")
random_file = files[Math.floor(Math.random() * files.length)]