Created
October 6, 2011 14:36
-
-
Save RobertBrewitz/1267552 to your computer and use it in GitHub Desktop.
Sort your download directory into weeks
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 | |
WEEK=$(/bin/date +%V) | |
if [ ! -d $HOME/Downloads/week-$WEEK ]; then | |
mkdir $HOME/Downloads/week-$WEEK | |
fi | |
downloadedFiles=($(find $HOME/Downloads -depth 1)) | |
fileCount=${#downloadedFiles[@]} | |
for (( i=0; i<${fileCount}; i++ )); | |
do | |
if [[ ! "${downloadedFiles[$i]}" =~ 'week-' ]]; then | |
if [[ ! "${downloadedFiles[$i]}" =~ 'crdownload' ]]; then | |
mv "${downloadedFiles[$i]}" "$HOME/Downloads/week-$WEEK/" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed bug where not done downloads would be moved if another file finished downloaded.