Skip to content

Instantly share code, notes, and snippets.

@amandavisconti
Created January 31, 2019 18:01
Show Gist options
  • Save amandavisconti/ffc05d293b9fed70a7378421f7c818f0 to your computer and use it in GitHub Desktop.
Save amandavisconti/ffc05d293b9fed70a7378421f7c818f0 to your computer and use it in GitHub Desktop.
Script from Joshua Johnson's post on how to automate screencaps (https://mac.appstorm.net/general/applescript-automatically-create-screenshots-from-a-list-of-websites/)
--Variables
set whichUrl to 1
set fileNames to "webshot"
--Get Number of URLs
tell application "TextEdit"
set theCount to the count of paragraphs of front document
end tell
--Repeat this for every URL
repeat theCount times
--Get the next URL
tell application "TextEdit"
set currentUrl to paragraph whichUrl of front document as text
end tell
--Open the URL in Safari
tell application "Safari"
activate
set the URL of document 1 to currentUrl
--Wait until it loads, then take a screenshot
delay 5
set picPath to ((POSIX path of (path to desktop)) & fileNames & "-" & whichUrl & ".jpg") as string
do shell script "screencapture -tjpg " & quoted form of picPath
end tell
--Increase the counter for next time
set whichUrl to whichUrl + 1
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment