Created
December 11, 2013 16:20
-
-
Save davidmerrique/7913493 to your computer and use it in GitHub Desktop.
Clean Desktop - Just moves files into a Desktop folder in Documents.
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
shopt -s nullglob | |
date="$(date "+%Y-%m-%d")" | |
folderTime="$(date "+%H%M%S")" | |
dest="/Users/$USER/Documents/Desktop/$date" | |
src=(/Users/$USER/Desktop/*) | |
files="/Users/$USER/Desktop/*" | |
if [ ${#src[@]} -gt 0 ]; then | |
if [ ! -d $dest ]; then | |
mkdir -p $dest | |
fi | |
if [[ ! -d "$dest/$folderTime" ]]; then | |
mkdir -p "$dest/$folderTime" | |
fi | |
for file in $files; do | |
mv "$file" "$dest/$folderTime" | |
done | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment