Created
January 27, 2024 05:11
-
-
Save met/9e5b808559db8b6159539c8d0ac8b048 to your computer and use it in GitHub Desktop.
Generate bat file for concatenating MP3. Each 18 MP3 from directory is added 2 times into one biger MP3 file
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
// Generate bat file for concatenating MP3. Each 18 MP3 from directory is added 2 times into one biger MP3 file | |
// Like this, but every line contains 2x18 mp3 files: | |
// ffmpeg -i "concat:50lang-1st-part-1-0001.mp3|50lang-1st-part-1-0002.mp3|50lang-1st-part-1-0003.mp3" -c copy 50lang-lesson-01.mp3 | |
const path = require('path'); | |
const fs = require('fs'); | |
const directoryPath = path.join(__dirname); | |
let fff = []; | |
fs.readdir(directoryPath, function (err, files) { | |
//handling error | |
if (err) { | |
return console.log('Unable to scan directory: ' + err); | |
} | |
//listing all files using forEach | |
files.forEach(function (file) { | |
// Do whatever you want to do with the file | |
fff.push(file); | |
}); | |
//console.log(fff.length); | |
let lesson = 1; | |
while (fff.length > 0) { | |
let cmd1 = ""; | |
let set1 = []; | |
for (let i = 1; i < 19; i++) { | |
set1.push(fff.shift()); | |
} | |
set1 = set1.concat(set1); // double the content | |
cmd1 = set1.join("|"); | |
let lessonStr = String(lesson); | |
if (lesson < 10) { | |
lessonStr = "0".concat(lessonStr); | |
} | |
console.log(`ffmpeg -i "concat:${cmd1}" -c copy 50lang-lesson-${lessonStr}.mp3`); | |
lesson += 1; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment