Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 0.78 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function del() {
  2.   while [ -n "$1" ]; do
  3.     if [ ! -e "$1" ]; then
  4.       echo "'$1' not found; exiting"
  5.       return
  6.     fi  
  7.  
  8.     local file=`basename -- "$1"`
  9.  
  10.     # Chop trailing '/' if there
  11.     file=${file%/}
  12.  
  13.     local destination=''
  14.  
  15.     if [ -e "$HOME/.Trash/$file" ]; then
  16.       # Extract file and extension
  17.       local ext=`expr "$file" : ".*\(\.[^\.]*\)$"`
  18.       local base=${file%$ext}
  19.  
  20.       # Add a space between base and timestamp
  21.       test -n "$base" && base="$base "
  22.  
  23.       destination="/$base`date +%H-%M-%S`_$RANDOM$ext"
  24.     fi  
  25.  
  26.     echo "Moving '$1' to '$HOME/.Trash$destination'"
  27.     \mv -i -- "$1" "$HOME/.Trash$destination" || return
  28.     shift
  29.        
  30.     afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/finder/move\ to\ trash.aif
  31.   done
  32. }