Last active
May 9, 2019 14:36
-
-
Save cgrusden/6aa7f797ada27736d37797900b3d3a27 to your computer and use it in GitHub Desktop.
Auto organize files into your /Downloads folder
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/sh | |
# About | |
# Our disk drives get huge because, well, files end up everywhere (or maybe you are way better at this than I am). | |
# Over the past 5 years my drive has bloated and there are all kinds of files everywhere. | |
# The first step is to ORGANIZE everything into buckets that make "sense". | |
# This script will move certain file types into directories. THats the first step of | |
# organizing as I build the script. Eventually, this script will auto run at the | |
# end of the day via a cronjob so all files stay organized 100% of the time | |
# How to run: sh organize.sh | |
# TODO: Auto-create all the directories (or else theyll be a ton of failures). | |
# you need to have all these ~/Downloads directories created first | |
# TODO: Be able to supply an argument to the script, like organize.sh ~/Documents, | |
# you don't have to change directories to run this script | |
# Directories | |
find . -type d -maxdepth 1 -exec mv {} ~/Downloads \; | |
# Applications | |
find . -iname '*.dmg' -type f -exec mv {} ~/Downloads/Applications \; | |
find . -iname '*.pkg' -type f -exec mv {} ~/Downloads/Applications \; | |
find . -iname '*.sh' -type f -exec mv {} ~/Downloads/Applications \; | |
# CompressedFiles | |
find . -maxdepth 1 -type f -iname '*.gz' -exec mv {} ~/Downloads/CompressedFiles \; | |
find . -maxdepth 1 -type f -iname '*.zip' -exec mv {} ~/Downloads/CompressedFiles \; | |
find . -maxdepth 1 -type f -iname '*.tgz' -exec mv {} ~/Downloads/CompressedFiles \; | |
# Media | |
find . -maxdepth 1 -type f -iname '*.mov' -exec mv {} ~/Downloads/Movies/ \; | |
find . -maxdepth 1 -type f -iname '*.mpg' -exec mv {} ~/Downloads/Movies/ \; | |
find . -maxdepth 1 -type f -iname '*.mp4' -exec mv {} ~/Downloads/Movies/ \; | |
find . -maxdepth 1 -type f -iname '*.mp3' -exec mv {} ~/Downloads/Movies/ \; | |
find . -maxdepth 1 -type f -iname '*.wav' -exec mv {} ~/Downloads/Movies/ \; | |
# Documents | |
find . -maxdepth 1 -type f -iname '*.md' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.pdf' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.doc' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.txt' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.pages' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.epub' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.html' -exec mv {} ~/Downloads/Documents/ \; | |
find . -maxdepth 1 -type f -iname '*.xml' -exec mv {} ~/Downloads/Documents/ \; | |
# Spreadsheets | |
find . -maxdepth 1 -type f -iname '*.xls' -exec mv {} ~/Downloads/Spreadsheets/ \; | |
find . -maxdepth 1 -type f -iname '*.csv' -exec mv {} ~/Downloads/Spreadsheets/ \; | |
find . -maxdepth 1 -type f -iname '*.pages' -exec mv {} ~/Downloads/Spreadsheets/ \; | |
find . -maxdepth 1 -type f -iname '*.xlsx' -exec mv {} ~/Downloads/Spreadsheets/ \; | |
find . -maxdepth 1 -type f -iname '*.numbers' -exec mv {} ~/Downloads/Spreadsheets/ \; | |
# Images | |
find . -maxdepth 1 -type f -iname '*.jpg' -exec mv {} ~/Downloads/Images/ \; | |
find . -maxdepth 1 -type f -iname '*.jpeg' -exec mv {} ~/Downloads/Images/ \; | |
find . -maxdepth 1 -type f -iname '*.png' -exec mv {} ~/Downloads/Images/ \; | |
find . -maxdepth 1 -type f -iname '*.tif' -exec mv {} ~/Downloads/Images/ \; | |
# Delete | |
find . -maxdepth 1 -type f -iname '*.crdownload' -exec rm {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment