I am using Node.js, and I want to obtain the parent directory name for a file. I have the file \"../test1/folder1/FolderIWant/test.txt\".
\"../test1/folder1/FolderIWant/test.txt\"
I want to get
Simplest way without any node modules like the path. You can easily do in the following manner to get the root folder name.
var rootFolder = __dirname.split('/').pop(); console.log(rootFolder);