Using Javascript I'd like to remove the filename from the end of a string (path+filename), leaving me just the directory path.
Would regular expressions be ideal? Or, is there a simpler means of doing this using the string object?
Thanks for any help!
----ANSWERED & EXPLAINED---
The purpose of this code was to open finder to a directory. The data I was able to extract included a filename - since I was only trying to open finder (mac) to the location, I needed to strip the filename. Here's what I ended up with:
var theLayer = app.project.activeItem.selectedLayers[0];
//get the full path to the selected file
var theSpot = theLayer.source.file.fsName;
//strip filename from the path
var r = /[^\/]*$/;
var dirOnly = theSpot.replace(r, '');
//use 'system' to open via shell in finder
popen = "open"
var runit = system.callSystem(popen+" "+"\""+dirOnly+"\"");