I am trying to rename the directories if it contains space in their name. It's renaming properly but after renaming call back function defined never called.
my recursive function in below, where fs for file system and complete-directory-tree.
function renameDir(dirs){
dirs.forEach(function(e){
if(e.name.match(/\s+/g)){
var cname = e.name.replace(/\s+/g,'_');
var cpath = e.path.replace(e.name,cname);
fs.rename(e.path,cpath,function(err,data){
if(err) console.log(err)
else{
console.log('success');
e.path = cpath;
e.name = cname;
}
});
}
var nested = cDT(e.path)
if( nested.children && (nested.children.length > 0) ) renameDir(nested.children);
});
}