This repository has been archived by the owner on Jul 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy-path-to-clipboard.jsx
75 lines (66 loc) · 1.75 KB
/
copy-path-to-clipboard.jsx
1
(function (thisObj) { var doc = app.activeDocument; if (doc === null) { alert("No document"); return; } if (doc.selection.length === 0) { alert("No selction"); return; } var sel = app.selection[0]; if (sel.hasOwnProperty('images')) { if (sel.images.length === 0) return; var link = sel.images[0].itemLink; if(link.needed === false){ alert("embedded"); return; } if(link.status == LinkStatus.LINK_MISSING){ alert("image is missing"); return; } if(link.needed === false){ alert("embedded"); return; } var path = link.filePath; var img = File(path); // alert(img.path); myScript = 'do shell script "echo \''+ img.path +'\' | pbcopy"'; app.doScript(myScript, ScriptLanguage.applescriptLanguage); message("--- copied " + img.path + " to clipboard ---", 2000); } else{ alert("Not a image frame"); }/** * Taken from ScriptUI by Peter Kahrel * @usage * var progress_win = new Window ("palette"); * * var progress = progress_bar(progress_win, 100, 'my Progress'); * * progress.value = i++; * progress.parent.close();// important close it!! * * @param {Palette} w the palette the progress is shown on * @param {Number} stop [description] * @return {Progressbar} [description] */function message ( labeltext, millisec) {var w = new Window ("palette");var txt = w.add('statictext',undefined,labeltext);// var pbar = w.add ("progressbar", undefined, 1, stop); pbar.preferredSize = [300,20];w.show ();sleep(millisec);w.close();}function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } }}})(this);