Skip to content

Instantly share code, notes, and snippets.

@Blaumaus
Created February 1, 2020 21:59
Show Gist options
  • Save Blaumaus/17b85ef3fb4285b890a2771df4fcd757 to your computer and use it in GitHub Desktop.
Save Blaumaus/17b85ef3fb4285b890a2771df4fcd757 to your computer and use it in GitHub Desktop.
A script to remove all the screenshots in ~/Pictures/ directory
#!/usr/bin/bash
# A script to remove all the screenshots in ~/Pictures/ directory
if [[ `ls ~/Pictures/ | grep "Screenshot\ from" | wc -l` -gt 0 ]]; then
before_size=`du -shb ~/Pictures | cut -f1`
echo "`rm -v ~/Pictures/Screenshot\ from*.png | wc -l` screenshots deleted!"
after_size=`du -shb ~/Pictures | cut -f1`
let "res=($before_size-$after_size)/1024"
# TODO: Show how much data was cleared dependently on it's size (KB, MB, GB, etc.)
echo "Cleared ${res}KB"
else
echo "There are no screenshots in ~/Pictures/ directory"
fi
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment