little bits of shell scripting
I got rid of the wiki, so I’ll just be blogging this kind of stuff. This is OSX specific, but I’m sure alternatives exist on linux and probably even windows. I wanted to take a screenshot every couple of seconds in the background and save the files with some kind of unique filename. First, create an empty directory for all the files, then run this one-liner from a bash shell.
while true; do screencapture -x -s $(date +%H%M%S); sleep 10; done
The -x parameter turns off the sound normally output on each screen capture. Ok, this will give you a screenshot with the timestamp as the filename in pdf format. To convert from pdf to png:
for i in ./*; do sips -s format png $i --out $i ; done
This will convert all the files in the directory to png format. There are probably more elegant ways of accomplishing this whole thing, but it worked for me when I need it to.