I Need to make this Javascript not output the entire path for the file location, only the filename is needed in the resulting file. What is the best way to go about this? Thanks
(function () {
var doc = app.activeDocument;
var myBaseName = doc.name;
var familyNames = [];
var i;
var names = [];
var styleNames = [];
var fontTypes = [];
if (/InDesign/.test(app.name)) {
familyNames = app.activeDocument.fonts.everyItem().fontFamily;
styleNames = app.activeDocument.fonts.everyItem().fontStyleName;
fileName = app.activeDocument.fonts.everyItem().location;
fontTypes = app.activeDocument.fonts.everyItem().fontType;
fontNames = app.activeDocument.fonts.everyItem().name;
for (i = 0; i < fontNames.length; i++)
{names.push([familyNames[i] + " " + styleNames[i], fileName[i], fontTypes[i]]);}
writeCsv("InDesign Document", names);
}
function writeCsv(program, names) {
var file;
var i;
file = new File("~/Desktop/" + myBaseName + "_fonts.csv");
file.encoding = "UTF-8";
file.open("w");
file.writeln("Font name,File name,Font type");
names.sort();
for (i = 0; i < names.length; i++) {
file.writeln(names[i].join(",") + "\r");
}
file.close();
alert("Output " + File.decode(file.fullName));
}
})();
Tried a few different methods, LastIndexOf('/')