Making Mac OS X Automatically Take Screenshots

Had a bit of an issue, thought it was worth a post, first in a while…

howto make mac osx automatically take timed screenshots every X seconds with a simple bash script

For programmers, open terminal

for i in {1..9999}; do echo “taking screen shot $i”; screencapture -x “helloworld$i.png”; sleep 1; done

For Editorial

Open Terminal

  1. Open finder
  2. go to the “Applications” Folder
  3. go inside the “Utilities” Folder
  4. run the “Terminal” application

Run the wee script which does the magic

  1. Go to the “Terminal” application
  2. type “cd”
  3. type a space
  4. Go to finder,
  5. open a folder you what the screen captures to happen in
  6. drag the icon of the folder into the “Terminal” application (this should make some text appear in the Terminal app like /Data/Applications or something)
  7. Go back to the “Terminal” application
  8. type return
  9. type ‘for i in {1..9999}; do echo “taking screen shot $i”; screencapture -x “helloworld$i.png”; sleep 1; done‘ exact character for character or copy and paste
  10. type return
  11. {at this point the computer should be taking screen shot every second}
  12. Do stuff, what ever you want to capture
  13. When you want to stop the capturing, simply quite “Terminal” the way you normally would

Improvements

  • sleep 1, controls the time between captures, so sleep 60 would take a capture every minute
  • {1..9999}, controls the amount of time, that means after 9999 loops it stops

my good friend dimitar has suggested a better loop which never stops unless stopped by the user

#! /usr/bin/env bash

i=0

while 1

do

((i++))

screencapture -T 1 “capture$i.jpg”

done

October 27th, 2011 5:31 am

Oh my goodness! an amazing write-up dude. Thanks However I’m experiencing issue with ur rss . Dont know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

November 28th, 2011 11:29 pm

Fantastically entertaining thank you, I do think your close audience would probably want a good deal more content familiar to this maintain the great hard work.

rey
December 26th, 2012 3:36 pm

ran the script above, with sleep 90.

after 10 hours I’ve been gone, I get screenshots from 1 to 9… and then screenshot n. 490
WTF happened to all the others? O_O

zapper
December 26th, 2012 4:12 pm

Wow a real non spam visitor, sorry mate place has been rather unmaintained the last few years while I my fortune as a it contractor.

To be honest I don’t know, in the terminal did you get all the “taking screen shot x messages ?”

Otherwise I don’t know what could cause it, try reducing the sleep time and seeing if its still broken, or failing that there could be a better way now in screencapture, try man screencapture, and see if there’s a repeat flag or something

Tell me how you get along, good luck ant

December 29th, 2012 11:17 pm

Funny, now you get your 2nd non-spam visitor in 3 days…when it rains it pours, eh?

I looked this up because I am early in being a self-employed web services provider and I want to document how long it takes me to get ‘x’ task done—right now just for me but I could see using it for client accountability later.

Anyway, I am not quite comfortable with Terminal yet so let me ask a few questions:
When you write ‘for developers’ are you just assuming they will know to do the ‘cd’ command part and that they will also know to denote a folder where the .pngs will be saved to?

Let’s say I create a folder in my ‘Pictures’ folder called ‘TimedScreenshots.’ If I understand what you wrote here I would:
1. open Terminal
2. type [cd_] without brackets, space represented by the underscore.
3. Navigate to /Pictures/
4. Open it, and drag /TimedScreenshots/ onto/into the open Terminal Interace (window).

Now, will the path that shows up in Terminal be the path to the ‘TimedScreenshots’ folder? (sorry, seeing ‘Data/Applications’ has me a bit spooked in case I do something wrong)

5. press the return/enter key
6. type [for i in {1..9999}; do echo “taking screen shot $i”; screencapture -x “helloworld$i.png”; sleep 1; done] (without the square brackets).
7. press the return/enter key

Adjust the frequency of screenshots via the [sleep 1] portion of the command, with the number used seconds between screenshots.

To stop I just quit Terminal.

Is this correct?

If I use the second variation from dimitar at what point (either by dragging a folder or by typing the path?) would I specify the location where the screenshots will be saved. Unmodified where would it save the screenshots?

You say the second variation has to be specifically stopped, does that mean quitting Terminal or would I need a command to force it to stop?

I have ScreenFlow, how would screenshots every second (let’s say .png files like in the first method because they tend to be bigger) compare in total file size to simply capturing a screenflow (for my use only)?

Thanks and great post.

*Name
*Mail
Website
Comment