Skip to content

Instantly share code, notes, and snippets.

@ukoasis
Created November 7, 2015 11:59
Show Gist options
  • Save ukoasis/7a67a9f1c04b1d8fda1b to your computer and use it in GitHub Desktop.
Save ukoasis/7a67a9f1c04b1d8fda1b to your computer and use it in GitHub Desktop.
var fs = require('fs');
var exec = require('child_process').exec;
fs.readdir('.', (err, files) => {
if (err) throw err;
var fileList = [];
files.filter((file) => {
return fs.statSync(file).isFile() && /.*\.m4a$/.test(file)
}).forEach((file) => {
file = __dirname + "/" + file
fileList.push(file);
});
console.log(fileList);
fileList.forEach((file) => {
outputFilename = file.replace(/m4a$/g, "mp3")
cmd = "ffmpeg -i \"" + file + "\" -ab 192000 \"" + outputFilename + "\""
console.log(cmd);
var result = exec(cmd);
console.log(result);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment