ADDENDUM : Your Workflow
Thanks for posting a screenshot of your workflow. There doesn't appear to be anything obstructive about it that would obviously cause it to stop responding to a shortcut.
However, I'm going to take the opportunity to suggest some edits to it, as I can see what your AppleScript is doing, but it's not doing it in the most optimal way.
Here is your current workflow:
It starts by taking the files/folders passed to the service/quick action and copying them to the clipboard. There's no need to and it only makes Automator do more work than it has to. Instead, you can delete that first action, and have the files/folders pass directly into the AppleScript, where they will be stored in the variable input
.
The AppleScript itself makes use of application "BBEdit"
unnecessarily, so I suggest removing that and I'll show you how to make the changes you need without calling out to it.
If I'm interpreting your goal correctly from what you said and from what I see in your workflow, you wish to select some files or folders, press your shortcut key combination, and have file URL references to those files/folders copied to the clipboard, e.g. file:///Users/CK/Desktop/somefile.txt
.
Your method works ok in some situations, but will produce incorrect results in a few other situations:
Any file/folder with a space in its name will not return a correct and clickable file URL link. For example, the file with path /Users/CK/Shared Items/myfile.ext
will be copied to the clipboard as file:///Users/CK/Shared Items/myfile.ext
, which is an incorrectly encoded URL string, thus the hyperlink will appear like this: file:///Users/CK/Shared
Items/myfile.ext
. (Technically, other character entities need to be percent encoded to form a valid URL, but I think they're less important if you're just looking to use them locally in Finder.)
Your present method replaces occurrences of "/Volumes"
and occurrences of "/Users"
with "file:///Volumes"
and "file:///Users"
, respectively. This will cause problems for any file path that might look something like this:
/Users/CK/Backup/Preferences/Volumesettings/Volumes.dat
There are three replacements waiting to happen there, which would yield:
file:///Users/CK/Backup/Preferencesfile:///Volumesettingsfile:///Volumes.dat
Having cleaned up the script, and deleted the superfluous action, here is what I am suggesting would be a smarter way to implement your service/quick action:
The AppleScript:
property text item delimiters : linefeed
on run {FSItems}
local FSItems
tell application "System Events" to repeat with FSItem in FSItems
set FSItem's contents to the URL of FSItem
end repeat
set the clipboard to FSItems as text
end run
It utilises System Events (which is a faceless, background application that can perform efficient file system operations) to take each file/folder passed into the workflow and obtain an AppleScript property named URL
, which conveniently holds the perfectly-formatted, validated file URL reference for a file. Once it has a list of file URLs, it combines them into a single piece of text—one file URL per line—and places that on the clipboard.
Thus, selecting the following files/folder in Finder (if you imagine I selected three files and a folder, then pressed the hotkey to trigger the service):
/Users/CK/Desktop/NSImage.png
/Users/CK/Desktop/GIF Images
/Volumes/Lepton 1.5.2-alpha-2
/Users/CK/Desktop/mandelbrot.js
would yield the following clipboard contents (this is a live test):
file:///Users/CK/Desktop/NSImage.png
file:///Users/CK/Desktop/GIF%20Images/
file:///Volumes/Lepton%201.5.2-alpha-2/
file:///Users/CK/Desktop/mandelbrot.js