Last active
September 9, 2021 19:10
-
-
Save PeterFaiman/d8964912eeba66be60c0ea5d15577eab to your computer and use it in GitHub Desktop.
Revisions
-
PeterFaiman revised this gist
Sep 9, 2021 . No changes.There are no files selected for viewing
-
PeterFaiman created this gist
Sep 9, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ on run args set theFiles to {} -- POSIX file throws an error inside tell Finder, so build a list -- before entering tell Finder. repeat with thePath in args set the end of theFiles to POSIX file thePath end repeat tell application "Finder" repeat with theFile in theFiles delete theFile end repeat end tell return end run 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ trash() { # AppleScript POSIX file needs absolute paths. local -a absolute_paths for relative_path in "$@"; do if [[ -e "$relative_path" ]]; then # :a - ZSH absolute path modifier. absolute_paths+=( "$relative_path"(:a) ) else # :a modifier only works on paths that exist. echo "$0: ${relative_path}: No such file or directory" >&2 fi done osascript ~/Code/AppleScripts/TrashFiles.applescript "${absolute_paths[@]}" }