5

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 Dec 11 '13 at 13:02
7

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
       2

References

https://stackoverflow.com/questions/20099333/terminal-command-to-show-connected-displays-monitors-resolutions
http://hintsforums.macworld.com/showthread.php?p=695603

| improve this answer | |
  • thanks. I thought I tried with two filenames, but now it seems to work... – jononomo Dec 11 '13 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 Oct 27 '17 at 21:27

You must log in to answer this question.

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