Get parent directory name in Node.js
What you want is path.basename
:
path.basename(path.dirname(filename))
Better use @danielwolf's answer instead
Use split()
and pop()
:
path.dirname(filename).split(path.sep).pop()
What you want is path.basename
:
path.basename(path.dirname(filename))
Better use @danielwolf's answer instead
Use split()
and pop()
:
path.dirname(filename).split(path.sep).pop()