Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

Wanted: Service Tweak this apple script please

Joined
May 10, 2007
Posts
1,972
Reaction score
288
Hi,

I'm trying to take screen grabs of a list of URLs.

I'm doing it on a local machine - to ensure the grabs all look perfect.

I've found an apple Script for Mac which does the job perfectly:
https://mac.appstorm.net/general/ap...y-create-screenshots-from-a-list-of-websites/

The only disadvantage is that it names the files webshot-1, webshot-2, rather than the URL of the page that the screen grab is of.

I've had a little play with this - but to no avail.

If anyone can help, that would be great.

Thanks, Phil
 
this works i think :

Code:
--Variables
set whichUrl to 1
set fileNames to "webshot"
set filename_text to ""

--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 current url as variable to be able to strip text
        set the filename_text to currentUrl
      
        set filename_text to ((characters 8 thru -1 of filename_text) as string) --trim first characters of current url
        set filename_text to ((characters 1 thru -6 of filename_text) as string) --trim last chracters of current url
      
        set picPath to ((POSIX path of (path to desktop)) & fileNames & "-" & filename_text & ".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

play around with the character trim bit if your using mostly co.uk or whatever so your not writing full stops in the file name
 
Last edited:

Rule #1: Be Respectful

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Systreg AcornBot:
    Systreg has left the room.
      Systreg AcornBot: Systreg has left the room.
      Top Bottom