Obtenha dir do filepath javaScript
path = path.substring(0,path.lastIndexOf("\\")+1);
Samiksha Singla
path = path.substring(0,path.lastIndexOf("\\")+1);
path.dirname("/home/workspace/filename.txt") // '/home/workspace/'