Me5 Me5 -4 years ago 321
Node.js Question

Get parent directory name in node.js

I am using node.js and I want to obtain the parent directory name for a file.
I have the file


I want to get

I have tried:

var path = require('path');
var parentDir = path.dirname(filename);

but it returns

Answer Source

Use split() and pop():

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download