Skip to content

Instantly share code, notes, and snippets.

@Nikamura
Created February 3, 2016 15:16
Show Gist options
  • Save Nikamura/53c3a0d9b2e02deb3002 to your computer and use it in GitHub Desktop.
Save Nikamura/53c3a0d9b2e02deb3002 to your computer and use it in GitHub Desktop.
Moves screenshot to directory on Mac
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