Skip to content

Commit dfd9acb

Browse files
authored
Add script to delete selected files in Finder (#1008)
* Add script to delete selected files in Finder This script allows users to quickly move selected files or folders to the Trash directly from Finder. Unlike existing trash scripts that operate on entire directories (Desktop, Downloads), this command works with any files/folders currently selected in Finder, making it more flexible and user-friendly. Features: - Works with multiple selected items (files and folders) - Handles filenames with spaces correctly - Executes silently without confirmation for quick workflow - Uses native Finder trash functionality * Remove code comments * Add macOS notification with item count * Delete all files in single operation * Update script author name
1 parent 0933fd7 commit dfd9acb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Delete Selected Files
6+
# @raycast.mode silent
7+
8+
# Optional parameters:
9+
# @raycast.icon 🗑
10+
# @raycast.packageName System
11+
12+
# Documentation:
13+
# @raycast.description Move selected files in Finder to Trash
14+
# @raycast.author Vicent Gozalbes
15+
# @raycast.authorURL https://github.com/vigosan
16+
17+
file_count=$(osascript <<'ENDAPPLE'
18+
tell application "Finder"
19+
set selectedItems to selection
20+
if (count of selectedItems) is 0 then
21+
return 0
22+
end if
23+
24+
delete selectedItems
25+
return count of selectedItems
26+
end tell
27+
ENDAPPLE
28+
)
29+
30+
if [ "$file_count" -eq 0 ]; then
31+
exit 1
32+
fi
33+
34+
if [ $file_count -eq 1 ]; then
35+
message="1 item moved to Trash"
36+
else
37+
message="$file_count items moved to Trash"
38+
fi
39+
40+
osascript -e "display notification \"$message\" with title \"Trash\""

0 commit comments

Comments
 (0)