-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.js
More file actions
33 lines (25 loc) · 752 Bytes
/
Copy pathlist.js
File metadata and controls
33 lines (25 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require("fs")
const path = require("path")
const getAllFiles = function(dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach(function(file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
} else {
arrayOfFiles.push(path.join(dirPath, "/", file))
}
})
return arrayOfFiles
}
let myfiles = getAllFiles(path.join(require('os').homedir() + '\\Videos'));
// myfiles.forEach(e => console.log(e));
let fileName = 'list-' + Date.now() + '.txt';
console.log(fileName)
myfiles.forEach(e => {
fs.appendFile(fileName, e + '\n', err => {
if(err){
throw err;
}
});
})