-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (32 loc) · 1.01 KB
/
index.js
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
34
35
/*jslint es6 */
'use strict'
const f2m = require("flac-to-mp3");
const fs = require('fs');
const path = require('path');
//
const flacFilePath = "C:\\temp\\del";//** YOUR FLAC DIRECTORY */
const dirPath = path.resolve(flacFilePath);
const ext = ".flac";
console.log("Flac to mp3 convertor - https://www.linkedin.com/in/gunjankumar/");
let filesList = [];
console.log(filesList);
fs.readdir(dirPath, function (err, files) {
filesList = files.filter(function (e) {
return path.extname(e).toLowerCase() === ext
});
if (filesList.length > 0) {
filesList.forEach(element => {
convertor(dirPath + "\\" + element);// windows concatenation
// use directory+file path concatenation / or \ as per your OS [mac or windows]
});
}
});
const convertor = (filePath => {
console.log(filePath);
f2m.convert(
filePath,
function (data) {
console.log(data.err.toString())//it will log detail in progress data, wait for completion
}
);
});