Skip to content

Instantly share code, notes, and snippets.

@davidmerrique
Created December 11, 2013 16:20
Show Gist options
  • Save davidmerrique/7913493 to your computer and use it in GitHub Desktop.
Save davidmerrique/7913493 to your computer and use it in GitHub Desktop.
Clean Desktop - Just moves files into a Desktop folder in Documents.
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