
To get file path of a file which you have copied on the your computer through ElectronJS depends on the operating system run the Electron application on.
In this article, I work on two popular operating system MacOs and Windows
On MacOS:
constfilePath=clipboard.read('public.file-url').replace('file://','');
On Windows:
constrawFilePath=clipboard.read('FileNameW');constfilePath=rawFilePath.replace(newRegExp(String.fromCharCode(0),'g'),'');
import{clipboard}from"electron";exportconstgetFilePathFromClipboard=()=>{letfilePath="";if(process.platform==="darwin"){filePath=clipboard.read("public.file-url").replace("file://","");}if(process.platform==="win32"){filePath=clipboard.read("FileNameW").replace(newRegExp(String.fromCharCode(0),"g"),"");}returnfilePath;};
I used above code for my love appXclippy
xclippy #osbkca
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse