Alan He Posted April 4, 2020 Posted April 4, 2020 (edited) When I select a pic , and ⌘ C, I will get file's name, but I need copied path. Because I will scp the file to my vps. When I operate like the following .I will get query ,but it's just filename Edited April 4, 2020 by Alan He
deanishe Posted April 4, 2020 Posted April 4, 2020 Then you'll need to access the pasteboard yourself to retrieve the path. When you copy an image file, the OS puts a bunch of formats on the pasteboard, including the image data, its path, its URL and a text representation. The text representation, which is what Alfred passes to workflows because it can only pass text, is just the filename. The following JXA script should return the path of a file you've copied in Finder: ObjC.import('AppKit'); function run() { // Get file URL from pasteboard let url = ObjC.unwrap($.NSPasteboard.generalPasteboard.stringForType('public.file-url')); // Decode URI and strip file:// prefix return decodeURI(url).substring(7); } Alan He 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now