Вы можете разделить имя файла, чтобы получить имя и расширение, обрезать имя и снова добавить расширение. Например:
function trimFileName(fileName){
var delimiter = fileName.lastIndexOf('.'), // fileName hold the whole name filename.ml4
extension = fileName.substr(delimiter), // the extension of the file
file = fileName.substr(0, delimiter); // just the name of the file
var filenameLen = 6; // adjust for the required filename length
return (file.length > filenameLen ? file.substr(0, filenameLen) + "..." : file) + extension;
}
Надеюсь, это то, что вы имели в виду.