I wanted to use screencapture to take a screenshot of all monitors from within a script, but this only seems to capture the main monitor. How can I use screencapture or any other tool callable from the command line to capture all monitors?

  • 1
    I've edited your question to keep it (and potential answers) within the scope as defined in the FAQ.
    – nohillside
    Commented Dec 11, 2013 at 13:02

1 Answer 1


It's poorly documented, but it is indeed possible with the screencapture command.

screencapture ~/Desktop/screen1.png ~/Desktop/screen2.png [...]

Here's the relevant section from man screencapture:

 files   where to save the screen capture, 1 file per screen

Of course, if you're calling it programmatically, you might not know how many monitors there are, so you'll have to parse the output of system_profiler SPDisplaysDataType or defaults read /Library/Preferences/com.apple.windowserver.plist to determine how many filename arguments to pass to screencapture. For example:

$ system_profiler SPDisplaysDataType | grep "Online: Yes" | wc -l



  • thanks. I thought I tried with two filenames, but now it seems to work...
    – tadasajon
    Commented Dec 11, 2013 at 15:13
  • 1
    It looks like passing extra arguments doesn't hurt anything so you could always specify like 10 files and assume you'll never have more than that many monitors!
    – dreeves
    Commented Oct 27, 2017 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .