Last active
May 16, 2018 14:54
-
-
Save Radcliffe/c57237456e8b69340f1ba9d29373aa68 to your computer and use it in GitHub Desktop.
Bash script to move downloaded files into current directory.
This file contains hidden or 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 | |
# 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