Skip to content

Instantly share code, notes, and snippets.

@Phlow
Last active October 11, 2015 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phlow/f107e15e17d11ef75cbd to your computer and use it in GitHub Desktop.
Save Phlow/f107e15e17d11ef75cbd to your computer and use it in GitHub Desktop.
Shell-Script renaming screenshots, making thumbnails and optimizing images with ImageOptim
#
# Rename Screenshots, Make Thumbnails, Optimize Images with Imageoptim
#
clear;
echo -e '\n- - - - - - - - - - - - - - - - -';
echo -e '\n Screenshotter V.1.0 ';
echo -e '\n- - - - - - - - - - - - - - - - -';
# Wenn Variablen gesetzt sind, dann bitte los...
if [[ -n "$1" && -n "$2" && -n "$3" ]]
# if [[ -n "$1" ]]
then
echo Screenshot-name: "$1";
echo Format: "$2";
echo -e 'Width:' "$3" '\n';
# Rename Screenshots
counter=1;
for i in *.*;
do new=$(printf "%02d.$2" "$counter");
mv -- "$i" "screenshot-$1-netlabel-$new";
let counter=counter+1
done;
# Make Copy
for i in screenshot*.$2; do cp $i `basename $i .$2`-thumb.$2; done
# Make Thumbs
for i in screenshot*-thumb.$2; do sips -Z $3 $i; done
# Optimize Thumbs
open -a ImageOptim .
else
echo -e '\n- - - - - - - - - - - - - - -\n FEHLER \n- - - - - - - - - - - - - - -\n';
echo -e 'Nicht genügend Variablen definiert\n'
echo Screenshot-name: "$1";
echo Format: "$2";
echo Width: "$3";
echo -e '\n\n\n';
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment