franzheidl Posted June 16, 2013 Posted June 16, 2013 (edited) Workflow for Alfred 2 to copy the paths of your current files and Documents to the clipboard in a variety of formats: * POSIX or HFS paths * '~/'-shortened POSIX paths * quoted paths * comma- or newline-separated. Works as a scriptfilter that gives you feedback how your paths would be copied: All options (except newline-separation) are available as File Actions also: More details in the README on github. Download: http://cl.ly/YX1Q Github: https://github.com/franzheidl/copy-paths-to-clipboard Edited November 15, 2014 by franzheidl 40-02, katie and _mk_ 3
franzheidl Posted June 18, 2013 Author Posted June 18, 2013 Just updated the scriptfilter to work with paths containing non-ASCII/Unicode characters. Use quoted option '-q' if you're copying for Terminal, otherwise Terminal won't understand such a path Pull from github or use updated download link above.
JolinM Posted October 16, 2013 Posted October 16, 2013 Hi franzheidl, I'm trying to simplify your script to only get the Posix. I created a new Alfred Workflow, running the Applescript to get the POSIX file path in your GIThub. I have no idea why, but the result I get is always follow by a paragraph return "/Applications/ " instead of "/Applications/" Any clue why I have this behaviour? Best
Januz Posted November 6, 2013 Posted November 6, 2013 Great workflow, thank you! What I really would like to have the possibility to either only copy (the default setting you implemented) or additionally paste (what one can select by changing the "Copy to Clipboard" part of the workflow) - at the moment one has to decide between one of the two options. Is that possible?!
franzheidl Posted December 15, 2013 Author Posted December 15, 2013 @JolinM, not sure If I fully understand what you're trying to accomplish – POSIX is the default path format anyway? Also not sure why you're getting the newline behaviour (if it is what you're on about), if I run it standalone it works just fine here.
franzheidl Posted December 15, 2013 Author Posted December 15, 2013 @Januz, much appreciated. So what you're after is 1.) Copy path(s) –– by default POSIX and then 2.) Paste the path and optionally have it converted just before pasting it in? That should be possible, although to me that sounds a bit like an edge/corner case, I usually copy paths for a purpose and already know what format I need them to be. Anyway, the problem is that you either can simply use Cmd-V to paste – then you'd need an additional intermediate step to modify the contents of the clipboard, OR you'd need to use an additional keyword for converting and pasting. The first option doesn't sound too sensible to me, the second should be possible but is a bit of the reverse of what I wanted the workflow to be. To make that possible regardless of what application you want to paste in you'd need Applescript GUI scripting (à la "keystroke "V" using {command down}").
JolinM Posted December 16, 2013 Posted December 16, 2013 Not sure; it's ben a while, and now everything's working great…
indros Posted May 30, 2014 Posted May 30, 2014 Could you help with a minor modification? I'm trying to prepend "file://" to the regular file path output so that I can link to local files from Evernote and other programs. When I open the "Copy to Clipboard" part of the workflow, it would seem I could do so by entering in file://{query}. But that doesn't seem to work. I suppose an Applescript could do the same, but I'm not a script kiddie and would have to go Googling for a how to. Could anyone help?
DrLulz Posted May 31, 2014 Posted May 31, 2014 I'm no "script kiddy" by a long shot, but you can setup a workflow with a keyword linked to a /usr/bin/osascript. this would grab the system link and copy it to the clipboard. the script is: on path2url(thepath) return do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv[1]))\" " & quoted form of thepath end path2url tell application "Finder" set sel to the selection as text set the clipboard to "file://localhost" & my path2url(POSIX path of sel) end tell
DrBull Posted July 29, 2014 Posted July 29, 2014 Hi franzheidl, Thank you for the very handy workflow! From your GitHub usage description: "Invoke the scriptfilter by typing paths . . . if you're in an other (document-based) application the path of your frontmost document will be copied." I wonder if this workflow can be easily adapted to the following scenario. Would it be possible to alter this workflow so that it could copy all of the paths of the open documents in an application? Sometimes I end up with quite a few Word documents open. I would like to be able to copy all of the paths of the open documents to the clipboard in one fell swoop so that I can then paste them into an omnioutliner file or store them in DEVONthink. Does anyone know how to do this or if there is already a workflow or script available that will do it? Thanks again franzheidl for making your workflow available. It is a time saver.
franzheidl Posted November 15, 2014 Author Posted November 15, 2014 Just added an option to copy the path(s) of the current document(s) or Finder item(s) as a properly encoded file url. Also changed the hfs option to use '-hfs' (incl. the leading hyphen), and updated the icons. GitHub: https://github.com/franzheidl/copy-paths-to-clipboard Download: http://cl.ly/YX1Q cands 1
gianthobbit Posted May 21, 2015 Posted May 21, 2015 Just added an option to copy the path(s) of the current document(s) or Finder item(s) as a properly encoded file url. Also changed the hfs option to use '-hfs' (incl. the leading hyphen), and updated the icons. GitHub: https://github.com/franzheidl/copy-paths-to-clipboard Download: http://cl.ly/YX1Q Is there a way I can delete options I don't want to use here? For example, I want the file link option only. I tried deleting items in the script and it just broke things:
patowod Posted October 6, 2017 Posted October 6, 2017 Hi everyone, I am having a bit of trouble getting remote server paths via copy paths. The pattern "smb://servername_or_ip/path…" would be what I actually need. Can someone push me in the right direction, please… How would I go about solving this? Until now I somehow always run in circles… Thanks in advance for any hints. What I get with Copy Paths to Clipboard (also tried all other options): /Volumes/path-to-whatever-file Desired outcome: with File Information – copy & paste full path: smb://servername/path-to-whatever-file
deanishe Posted October 6, 2017 Posted October 6, 2017 3 hours ago, patowod said: I am having a bit of trouble getting remote server paths via copy paths Well, that's kind of the whole point… The system makes network volumes look like normal, local volumes to applications. You might be able to get the source of the volume using a command like df or system_profiler SPNetworkVolumeDataType.
Jasondm007 Posted December 19, 2018 Posted December 19, 2018 @franzheidl Thanks for sharing your workflow! It's great, and I use it quite a bit. It's not a big deal, but I wanted to give you heads up that the "Copy file URL to Clipboard" action doesn't appear to work with filenames that contain a comma. Thanks again for posting this workflow!
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