Skip to content

Instantly share code, notes, and snippets.

@Radcliffe
Last active May 16, 2018 14:54
Show Gist options
  • Save Radcliffe/c57237456e8b69340f1ba9d29373aa68 to your computer and use it in GitHub Desktop.
Save Radcliffe/c57237456e8b69340f1ba9d29373aa68 to your computer and use it in GitHub Desktop.
Bash script to move downloaded files into current directory.
#!/bin/bash
# This script moves files from the Download directory to the current directory.
# Usage examples:
# pop - move the most recently downloaded file.
# pop 3 - move the three most recently downloaded files.
downloads=$HOME/Downloads
n=1
if [ "$1" != "" ]; then
n=$1
fi
for i in `seq 1 $n`;
do
last=$(ls -t $downloads | head -1)
echo "Moving $last to current directory."
mv "$downloads/$last" .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment