Copy link to clipboard
Copied
I have a script that exports images at different sizes and depending on the name it will write to text document a path to that image. So Example.jpg is located in Server-1/A-F or Server-1/G-K etc. What I would like to do is instead of writing that to a text file, would be to load it to the clipboad so I could paste it in an email, is this possible?
Copy link to clipboard
Copied
Use the search function : this has been already discussed many times :
Copy link to clipboard
Copied
It would be helpful if you posted the code for the script you're using...
"I have a script that exports images at different sizes and depending on the name it will write to text document a path to that image".
It seems like it would be an easy change from writing to a text file to getting that info copied to the clipboard.
Regards,
Mike
Copy link to clipboard
Copied
Hi @davidn5918184 , I use these 2 functions for getting and setting the clipboard. So assuming you have an image direct selected, this copies its file path to the clipboard:
/**
* Sets the clipboard to the provided string
* @ return void
*/
function setClipboard(s){
var tf = app.activeDocument.pages[0].textFrames.add()
tf.parentStory.texts[0].select();
tf.parentStory.contents = s;
tf.parentStory.texts.everyItem().select(SelectionOptions.REPLACE_WITH)
app.copy()
tf.remove()
}
/**
* Gets the clipboard text contents
* @ return the clipboard‘s text as a string
*/
function getClipboard(){
var tf = app.activeDocument.pages[0].textFrames.add()
tf.parentStory.texts[0].select()
app.paste()
var cb = tf.parentStory.contents.toString();
tf.remove()
return cb
}
Copy link to clipboard
Copied
Thank you. The difference is I want to load the clipboard with a string, but this is interesting, app.copy(). Could you put a varible in there?
Copy link to clipboard
Copied
Yes, you could probably use app.copy() to change from writing to a text file to getting that info copied to the clipboard.
If you have a single image selected you could try this..
//Copy Full Path
app.menuActions.itemByID(132623).invoke();
Regards,
Mike
Copy link to clipboard
Copied
Could you put a varible in there?
Sorry I forgot to include the call. With an image selected run this—imgPath is the image’s file path as a string:
var imgPath = app.selection[0].itemLink.filePath;
setClipboard(imgPath)
/**
* Sets the clipboard to the provided string
* @ return void
*/
function setClipboard(s){
var tf = app.activeDocument.pages[0].textFrames.add()
tf.parentStory.texts[0].select();
tf.parentStory.contents = s;
tf.parentStory.texts.everyItem().select(SelectionOptions.REPLACE_WITH)
app.copy()
tf.remove()
}
My clipboard in Mail pastes this:
ARCHIVE 8T:PHOTOGRAPHY & ART:PHOTOGRAPHY:EBAY:Woody Jackson:Rubin'sCow01