Declutter App

Working in a creative ad agency, I dealt a lot with cluttered desktops and digital disorganization. Organizing one’s desktop is pretty simple but when dealing with 500 machines, a script can help. I created the script below to organize a user’s desktop files by extension. It can be a little dangerous as it overwrites files without asking, so I wouldn’t recommend giving this out on a user level, keep it on a sysadmin use level.

#!/bin/sh
cd ~/Desktop
for file in *.??? ; do
 [ -f “$file” ] || continue
 dir=”$(echo “$file” | rev | cut -c-3 | rev)”
 mkdir -p “$dir” || { echo “Couldn’t mkdir -p $dir; exiting” ; exit 1 ; }
 mv — “$file” “$dir”
done

Originally published at medium.com on June 5, 2016.