Created
January 15, 2012 22:17
-
-
Save gammy/1617688 to your computer and use it in GitHub Desktop.
# Import sequential filenames with bash, ls, wc, date and import.
This file contains 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
#!/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