Node.js에서
Google에
Node.js file list in directory
를 검색하고
How do you get a list of the names of all files present in a directory in Node.js?
I'm trying to get a list of the names of all the files present in a directory using Node.js. I want output that is an array of filenames. How can I do this?
stackoverflow.com
여기에 접속한 후 예시코드를 확인
var testFolder = './data'; //지금 코드를 작성하고 있는 폴더 내의 data라는 폴더에 파일을 확인하고 싶음
var fs = require('fs');
fs.readdir(testFolder, function(err, filelist) { //파일목록을 filelist라는 변수로 지정
console.log(filelist); //파일목록을 출력
})
결과값
[ 'CSS', 'HTML', 'JavaScript' ]
data라는 폴더 내의 파일목록을 배열로 저장해서 보여줌
시간이 헛되지 않는 글이 되겠습니다.
I'll write something that won't waste your time.