Last active
January 30, 2025 13:54
-
-
Save ivanistheone/9daa23ae2a7abb472cb2 to your computer and use it in GitHub Desktop.
A shell script I use to (mostly) automatically cleanup my ~/Desktop
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 | |
MYHOME=$HOME | |
MYDESKTOP=$HOME/Desktop | |
echo " _ " | |
echo " | | " | |
echo " ___ | | ___ __ _ _ __ _ _ _ __ " | |
echo " / __|| |/ _ \/ _ | '_ \| | | | '_ \ " | |
echo " | (__ | | __/ (_| | | | | |_| | |_) |" | |
echo " \___||_|\___|\__,_|_| |_|\__,_| .__/ " | |
echo " | | " | |
echo " |_| v0.1 " | |
echo " " | |
cd $MYDESKTOP | |
DIRS="Content Papers Code Images Music Videos Links Archives Webpages Progs" | |
for dir in $DIRS; do | |
mkdir $dir | |
done | |
# make the final dest dir... | |
mkdir "desktop `date "+%Y-%m-%d"` " | |
for file in $MYDESKTOP/*; do | |
#echo "found file $file ... " | |
case $file in | |
*.pdf | *.PDF | *.doc | *.ps | *.ppt | *.ods | *.rtf | *.xlsl | *.xsl ) | |
echo "Moving $file to Papers/" | |
mv "$file" Papers/ | |
;; | |
*.py | *.pyc | *.php | *.php4 | *.php5 | *.pl | *.java | *.c | *.js | *.m | *.csv | *.cpp | *.R | *.hs ) | |
echo "Moving $file to Code/" | |
mv "$file" Code/ | |
;; | |
*.tex | *.log | *.textClipping ) | |
echo "Moving $file to Content/" | |
mv "$file" Content/ | |
;; | |
*.gif | *.png | *.PNG | *.jpg | *.JPG | *.jpeg | *.tiff | *.bmp | *.gcx | *.svg | *.ico ) | |
echo "moving $file to to Images/" | |
mv "$file" Images/ | |
;; | |
*.aiff | *.sd2 | *.wav | *.mp3 | *.ogg | *.pls ) | |
echo "moving $file to to Music/" | |
mv "$file" Music/ | |
;; | |
*.wmv | *.mov | *.WMV | *.flv | *.avi | *.mp4 | *.mpg | *.m4v ) | |
echo "moving $file to to Videos/" | |
mv "$file" Videos/ | |
;; | |
*.exe | *.EXE) | |
echo "moving $file to to Progs/" | |
mv "$file" Progs/ | |
;; | |
*.webloc | *.lnk | *.desktop) | |
echo "Moving $file to Links..." | |
mv "$file" Links/ | |
;; | |
*.zip | *.gz | *.tgz | *.tar | *.dmg | *.iso | *.iso.md5sum | *.deb | *.pkg | *.bz2 | *.rar | *.mpkg | *.torrent ) | |
echo "Moving $file to Archives... " | |
mv "$file" Archives/ | |
;; | |
*.html | *.htm | *.webarchive) | |
echo "Moving $file to Webpages..." | |
mv "$file" Webpages/ | |
mv "${file%.*} Files" Webpages/ | |
mv "${file%.*}_files" Webpages/ | |
;; | |
*) echo "Sorry, I don't know what kind of file $file is!" | |
esac | |
done | |
#delete empty dirs | |
for dir in $DIRS; do | |
rmdir $dir # will fail if files were put into it | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment