Skip to content

Instantly share code, notes, and snippets.

@RobertBrewitz
Created October 6, 2011 14:36
Show Gist options
  • Select an option

  • Save RobertBrewitz/1267552 to your computer and use it in GitHub Desktop.

Select an option

Save RobertBrewitz/1267552 to your computer and use it in GitHub Desktop.
Sort your download directory into weeks
#! /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
@RobertBrewitz

Copy link
Copy Markdown
Author

Automator illustration @ http://twitpic.com/6w08ez/full

@RobertBrewitz

Copy link
Copy Markdown
Author

Fixed bug where not done downloads would be moved if another file finished downloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment