Last active
April 25, 2025 14:24
-
-
Save hujunfeng/ee626bf37ac5aea77915c6a71da20b29 to your computer and use it in GitHub Desktop.
Raycast Script Command: Open Finder Selection in File Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Open Finder Selection in File Search | |
# @raycast.mode silent | |
# | |
# Optional parameters: | |
# @raycast.packageName Utilities | |
# @raycast.icon 📂 | |
tell application "Finder" | |
set selectedItems to selection | |
if selectedItems is not {} then | |
set firstItem to item 1 of selectedItems | |
set filePath to POSIX path of (firstItem as alias) | |
set encodedFilePath to (filePath as string) | |
if encodedFilePath ends with "/" then | |
set encodedFilePath to text 1 thru -2 of encodedFilePath | |
end if | |
set raycastURL to "raycast://extensions/raycast/file-search/search-files?fallbackText=" & encodedFilePath | |
do shell script "open " & quoted form of raycastURL | |
else | |
display notification "No file selected in Finder." with title "File Not Selected" | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment