Skip to content

Instantly share code, notes, and snippets.

@Thiruppathi
Last active October 28, 2020 17:18
Show Gist options
  • Save Thiruppathi/1072f67e445495407d9624837cf57a56 to your computer and use it in GitHub Desktop.
Save Thiruppathi/1072f67e445495407d9624837cf57a56 to your computer and use it in GitHub Desktop.
// Custom code to rename files.
/* 1. Create Lesson.json
{ "01-01" : "01. Title" }
*/
/* 2. Make sure the file names are in "01-01.mp4" format*/
const fs = require('fs');
fs.readFile('lesson.json', function(error, data) {
if (error) {
console.log(error);
return;
}
var obj = JSON.parse(data);
for(var p in obj) {
fs.rename(p + '.mp4', obj[p] + '.mp4', function(err) {
if ( err ) console.log('ERROR: ' + err);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment