Last active
March 18, 2017 04:57
-
-
Save mpppk/b0749ee57aafe885e81fe152abbbbc29 to your computer and use it in GitHub Desktop.
wav2mp3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// execute 'brew install lame' before use this script | |
const fs = require('fs'), | |
path = require('path'), | |
execSync = require('child_process').execSync, | |
srcDir = process.argv[2] || '.', | |
dstDir = process.argv[3] || 'mp3'; | |
try{ fs.mkdirSync(dstDir); }catch(e){} | |
fs.readdir(srcDir, (err, files) => { | |
if (err) throw err; | |
files | |
.filter(f => fs.statSync(f).isFile() && /.*\.wav$/.test(f)) | |
.map(f => `lame --preset extreme '${f}' '${dstDir}/${path.basename(f, '.wav')}.mp3'`) | |
.forEach(cmd => { console.log(cmd); execSync(cmd);}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment