Skip to main content

macos/trash

1#!/usr/bin/env bash
2# Move one or more files to the Trash in macOS.
3#
4# Examples:
5#
6# trash ~/Desktop/cat.jpg # Trash a single file
7# trash ~/Desktop/photos # Trash a folder
8# trash dog.png fish.gif # Trash multiple files at once
9#
11osascript -e 'on run argv
12 repeat with filePath in argv
13 set posixPath to (POSIX file filePath)
15 tell application "Finder"
16 if posixPath exists
17 log filePath
18 delete posixPath
19 end if
20 end tell
21 end repeat
22end run' "$@" 2>&1 1>/dev/null