AppleScript: copy file to clipboard

applescriptcopy/paste

So I've got the following:

set mypath to /Users/myuser/Desktop/file.pdf

I want to copy the file of this path to my clipboard. How to I do this?
I tried:

set the clipboard to the file mypath

This does not work. Any idea? I just want to be able to copy this file to any application using the clipboard.

Best Answer

There are several clipboards, so even if your file managed to fit in the clipboard, all applications is so broad that it's certain many or most will not grab the file contents as you expect/intend and instead grab a name of the file or pe haps the path.

The receiving application decides what to pull off the clipboard and not the script that places something in the clipboard.

You'll likely need to write specific scripts for specific apps and potentially re-evaluate AppleScrips since it might not be the correct tool for this job.