Skip to content

Commit c767229

Browse files
authored
system: copy selected finder file(s) to clipboard (#952)
* system: copy selected finder file(s) to clipboard * update comments
1 parent 3611492 commit c767229

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/osascript
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Copy Finder Selection to Clipboard
6+
# @raycast.mode silent
7+
# @raycast.packageName System
8+
#
9+
# Optional parameters:
10+
# @raycast.icon ??
11+
#
12+
# Documentation:
13+
# @raycast.description Copy contents of selected items in Finder to the clipboard. If there's more than one file selected, they will be combined and added to the clipboard.
14+
# @raycast.author Felipe Turcheti
15+
# @raycast.authorURL https://felipeturcheti.com
16+
17+
on run
18+
log "Copying contents of the selected items to the clipboard..."
19+
20+
tell application "Finder"
21+
-- get Finder selected items
22+
set theItems to selection
23+
end tell
24+
25+
-- create a list to store contents of all selected items
26+
set allContents to ""
27+
28+
-- for each item in the Finder selection
29+
repeat with itemRef in theItems
30+
-- get the item path
31+
set theItem to POSIX path of (itemRef as string)
32+
-- read the content of the item
33+
set fileDescriptor to open for access (POSIX file theItem)
34+
set fileContent to read fileDescriptor for (get eof fileDescriptor)
35+
close access fileDescriptor
36+
-- add the content to the list
37+
set allContents to allContents & fileContent & "
38+
"
39+
end repeat
40+
41+
-- set the clipboard to the combined contents
42+
set the clipboard to allContents
43+
end run

0 commit comments

Comments
 (0)