Saturday, 13 August 2022

How copy file to clipboard using python or CL to paste it using STRG+V later on?

I am trying to copy (using python or a CL command which I then can call using python) a file to the clipboard to later paste it using STRG+V. As far as I understand it, files are not "moved" into the clipboard, but rather the clipboard holds the path and an argument/flag that tells the OS "this is a file". I am happy with a linux-specific answer, but a universal answer would be the cherry on top.

pyperclip

Is not a solution, because it doesn't allow to copy files, just strings.

xclip

Is not a solution, because it only copies text

xclip-copyfile

Is not a solution, because it only copies to the X clipboard, not the clipboard. While xclip offers the option -selection clipboard (but only copies text), xclip-copyfile has no such option.

Using find

find ${PWD} -name "*.pdf"| xclip -i -selection clipboard -t text/uri-list

is a command described here: https://askubuntu.com/questions/210413/what-is-the-command-line-equivalent-of-copying-a-file-to-clipboard#answer-210428

But I can't replicate copying files with it and therefore assume that it is not working for all files.



from How copy file to clipboard using python or CL to paste it using STRG+V later on?

No comments:

Post a Comment