Last active
January 1, 2025 18:07
-
-
Save rsnemmen/6b787b1bcff3798067fc94318d9b09d5 to your computer and use it in GitHub Desktop.
Apple script to save the URLs of all currently open tabs in Safari to a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Set up the initial document | |
set output to ("List of open tabs in Safari" & linefeed as string) & "=======================" & linefeed as string | |
tell application "Safari" | |
-- Count the number of Windows | |
set numWindows to number of windows | |
repeat with w from 1 to numWindows | |
--Count the number of Tabs | |
set numTabs to number of tabs in window w | |
repeat with t from 1 to numTabs | |
-- Set the Tab Name and URL values | |
set tabName to name of tab t of window w | |
set tabURL to URL of tab t of window w | |
-- Create the Tab link and write the code | |
set output to output & tabURL & " " & tabName & linefeed as string | |
end repeat | |
end repeat | |
end tell | |
-- Write the entire document to TextEdit | |
tell application "TextEdit" | |
activate | |
make new document | |
set the text of the front document to output | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As an alternative for saving groups of tabs for future use, I highly recommend the safari add-on Tab Space.