Last active
April 3, 2016 03:35
-
-
Save habovh/a2a430eb67e67efec712b85f7be4e310 to your computer and use it in GitHub Desktop.
Little trash script for use with OS X. Mimics Finder's behavior when deleting a file that has the same name as a file already present in the trash, with a bonus.
This file contains 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 characters
#!/bin/bash | |
for file in "$@"; do | |
filename=$(basename "$file") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
dest="$HOME/.Trash/$filename.$extension" | |
if [ -f "$dest" ]; then | |
dest="$HOME/.Trash/$filename.$(date +%Y.%m.%d\ %H.%M.%S).$extension" | |
fi | |
mv "$file" "$dest" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment