Hi Chris, This script looks promising. How would you add the enclosing “<“ and “>” to make the file URI into a clickable markdown link?
I’ll take a look at the user manual for Attachment Scripts. I suppose I could try looking at this from another angle - i.e., do the processing when trying to follow the link? For example: Type backticks to enclose the dropped path as code to prevent the markdown processor from interpreting underscores, etc.: `` Drop the file path between the backticks using drag and drop with the Cmd key (note my filename has underscores and spaces): `/Users/craigh/Documents/my_test file.pdf` Follow the link by clicking anywhere in the path (delimited by the backticks) with whatever key modifiers (Cmd, Opt, etc.) have be configured and have a script grab the entire path, encode it, then follow it like a link - i.e., the same as if you Cmd-click on the following: <file:// <file:///Users/craigh/Documents/my_test%20file.pdf>/Users/craigh/Documents/my_test%20file.pdf <file:///Users/craigh/Documents/my_test%20file.pdf>> The advantage of this approach is that I don’t have to do anything special on the front end to get the path into my BBEdit document and it works for any file type or folder… Thanks, Craig > On Jan 11, 2022, at 1:31 AM, Christopher Waterman <[email protected]> > wrote: > > Craig, > > If you drag and drop a text file on to an open bbedit doc it will insert the > contents at the cursor. > But if you hold the cmd key it will insert and select a path. > > You could then run a script to encode it. > > Here is an example that works for me but I haven’t tested much. > Install it into BBEdits Scripts folder if want to give it a try. > > > Make File URI.applescript > ————————————— > > tell application "BBEdit" > tell window 1 > set _path to selection as text > set _cmd to "ruby -rURI -e " > try > set _uri to do shell script _cmd & quoted form of > ("puts URI.join( \"file:///\", URI.escape(\"" & _path & "\".chomp) )") > on error > set _uri to _path > end try > set selection to _uri > end tell > end tell > > —————————————— > > It will change this (the dropped path): > /Users/chris/Desktop/untitled text 10.txt > > Into this: > file:///Users/chris/Desktop/untitled%20text%2010.txt > > Food for thought: > > BBEdit has something called Attachment Scripts that allow you to invoke a > script on an event. > Page 343 from the user manual ( found in the Help menu ). > > I don’t think they have an attachment point for dropped text files, they > recently added one for dropped image files. > But you could have an attachment script run a text filter and convert all the > paths in the doc into file URIs when you save or something. > > Best of luck with your workflow, > Chris(topher)? > > > > -- > This is the BBEdit Talk public discussion group. If you have a feature > request or need technical support, please email "[email protected]" > rather than posting here. Follow @bbedit on Twitter: > <https://twitter.com/bbedit> > --- > You received this message because you are subscribed to the Google Groups > "BBEdit Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/bbedit/BD10F8EB-ADCB-410F-B634-4048AA8B4C1B%40rustydogink.com. > -- Craig Heilman Bugaboo Software -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/60E7BB3E-9C64-401E-9353-DF942D00983A%40bugsoft.com.
