mds08011 / shell-scripts

GNU General Public License v3.0
0 stars 0 forks source link

Add cleanup #4

Open mds08011 opened 2 years ago

mds08011 commented 2 years ago

I have a file called ''cleanup.sh'' which I run whenever my Desktop folder gets too crowded (my browser saves stuff to the desktop).

!/bin/bash

MYHOME=$HOME MYDESKTOP=$HOME/Desktop

echo " _ " echo " | | " echo " | | " echo " / || |/ \/ | ' | | | | ' \ " echo " | ( | | / (| | | | | || | |) |" echo " _|||\|_,|| ||_,| ._/ " echo " | | " echo " || v0.1 " echo " "

cd $MYDESKTOP DIRS="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 | .textClipping) echo "Moving $file to Papers/" mv "$file" Papers/ ;; .py | .pyc | .php | .php4 | .php5 | .pl | .java | .c | .js | .m | .csv | .tex | .log | .cpp ) echo "Moving $file to Code/" mv "$file" Code/ ;; .gif | .png | .PNG | .jpg | .JPG | .jpeg | .tiff | .bmp | .gcx | .svg ) 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/${file%.} Files" mv "${file%.}_files" "Webpages/${file%.}_files" ;; ) 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

I then put all these subfolders into a folder titled desktop YYYY-MM-DD (something descriptive) and my life gets better (for a couple of days).

It doesn't clean things up, but at least it gets the files out of the way. I often use the labels to find stuff. Eg.

desktop 2012-11-20 (Berlin) desktop 2012-12-07 (cleanup after book launch rush) desktop 2012-12-26 (ka-lite, web dev stuff, pre-NoBS launch) desktop 2013-03-01 (day at the Spundge offices)