[Adobe ExtendScript] Get filename information of a Document object

/* Get full path of document */ Document.prototype.getFullPath = function() { if(this.saved) { return this.fullName.fsName; } else { return false; } }; /* Get full path of the folder of the document */ Document.prototype.getFolderPath = function() { var path = this.getFullPath(); if(!path) { return false; } else { return path.substring(0, path.lastIndexOf("\\")); } }; /* Get file name of document */ Document.prototype.getFileName = function() { var path = this.getFullPath(); if(!path) { return false; } else { return path.substring(path.lastIndexOf("\\") + 1, path.lastIndexOf(".")); } }; /* Get file extension of document, including dot */ Document.prototype.getFileExtension = function() { var path = this.getFullPath(); if(!path) { return false; } else { return path.substring(path.lastIndexOf(".")); } };

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.