6 Replies Latest reply: Feb 22, 2008 3:16 PM by BenChase
BenChase Level 1 Level 1 (10 points)
I am not sure what the commands are but all I want it to do is take a screen shot every 30 sec and save the files with different names in a folder.
  • dev_sleidy Level 4 Level 4 (1,570 points)
    Launch 'Terminal' and enter ...

    man screencapture

    ... and press the <return> key; or,

    screencapture -h

    ... and press the <return> key.

    Once you have decided how to utilize 'screencapture' place ...

    do shell script "screencapture ..."

    ... within your specific AppleScript code - which calls 'screencapture' every n seconds over period y (where 'x' and 'y' are specific to your needs).
  • BenChase Level 1 Level 1 (10 points)
    So this is what I have but nothing seems to be happening

    tell application "Finder"
    repeat 900 times
    do shell script "screencapture -ct ~/Desktop/test"
    delay 30
    end repeat
    end tell

    Message was edited by: BenChase
  • dev_sleidy Level 4 Level 4 (1,570 points)
    In your code, 'tell application "Finder"' and its 'end tell' are not needed, no file name is provided; and, nor is a file format for '-t' provided.

    Code sample -

    set dFolder to "~/Desktop/screencapture/"

    do shell script ("mkdir -p " & dFolder)

    repeat with i from 1 to 900 -- Repeat 900 times.
    do shell script ("screencapture -c " & dFolder & (i as string) & ".png") -- Where '-c' copies the screen shot to the clipboard.
    delay 30 -- Wait for 30 seconds.
    end repeat

    Entering ...

    mac unix +screencapture

    ... into a search engine presents many results.
  • BenChase Level 1 Level 1 (10 points)
    Thanks,

    That seemed to work a lot better. I took out the "-c" so that it would save the file to the folder. What if I wanted to have the file name be the time with seconds. Is that possible?
  • dev_sleidy Level 4 Level 4 (1,570 points)
    set dFolder to "~/Desktop/screencapture/"

    do shell script ("mkdir -p " & dFolder)

    repeat 900 times -- Repeat 900 times.
    set tTime to do shell script "date +%H%M%S"
    do shell script ("screencapture " & dFolder & tTime & ".png") -- Capture screen.
    delay 30 -- Wait for 30 seconds.
    end repeat

    To include the date, as well ...

    set dFolder to "~/Desktop/screencapture/"

    do shell script ("mkdir -p " & dFolder)

    repeat 900 times -- Repeat 900 times.
    set dateTime to do shell script "date +%Y%m%d_%H%M%S"
    do shell script ("screencapture " & dFolder & dateTime & ".png") -- Capture screen.
    delay 30 -- Wait for 30 seconds.
    end repeat
  • BenChase Level 1 Level 1 (10 points)
    You are Awesome! Thanks for the help on this one. This was a lot more complex than I thought it would be, at least for my level of understanding!