Skip to content

Instantly share code, notes, and snippets.

@gammy
Created January 15, 2012 22:17
Show Gist options
  • Save gammy/1617688 to your computer and use it in GitHub Desktop.
Save gammy/1617688 to your computer and use it in GitHub Desktop.
# Import sequential filenames with bash, ls, wc, date and import.
#!/bin/bash
# Import sequential filenames.
dst="$HOME/Pictures/screenshots/"
if [ ! -d "$dst" ]; then
echo "\"$dst\" is not a directory."
exit 1
fi
prefix=$(date +"$dst/screenshot_%y%m%d-")
let num=(1 + $(ls $prefix* | wc -l))
filename=$(printf "%s%03d.png" $prefix $num)
imlib2_grab "$filename" ||
import -window root "$filename" &&
xmessage -timeout 2 -buttons "" -center "Saved \"$filename\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment