[Adobe ExtendScript] Return the matching Document object of a File object, and open the file if necessary

File.prototype.asDocument = function() { var document = false; for(var i = 0; i < app.documents.length; i++) { switch(app.documents[i].getFullPath() ) { case false: alert("Please make sure no unsaved files are open before continuing."); exit(); case this.getFullPath(): document = app.documents[i]; break; } } if(!document) { app.open(this); document = app.documents[0]; } return document; };

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.