Created
February 3, 2016 15:16
-
-
Save Nikamura/53c3a0d9b2e02deb3002 to your computer and use it in GitHub Desktop.
Moves screenshot to directory on Mac
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
function mv_screen() { | |
# Lecture id for folder | |
course="$*" | |
# Folder to where captured screenshots are stored | |
sf=~/"Desktop" | |
# Where images are stored | |
path="../Google Drive/Revision/$course/" | |
while : | |
do | |
# Find the newest captured screenshot | |
cd "$sf" | |
newest=$(ls -t | head -n1) | |
if [ "${newest##*.}" != "png" ]; then | |
echo "No new screenshot found on the desktop!"; | |
sleep 10s | |
mv_screen $course | |
fi | |
# Find the last moved screenshot and add +1 | |
cd "$path" | |
latest=$(ls -t | head -n1) | |
number=$((1 + ${latest%.png})) | |
cd $sf | |
mv "$newest" "$path/$number.png" | |
echo "Filename: $number.png" | |
sleep 10s | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment