Sometimes I'd like to be able to save a list of what web pages are open in the Safari browser's tabs. Using Apple's AppleScript scripting language it is possible to record that information to a text file. The following script will create a text file that lists each Safari browser window that is open and for each tab within a window, the title for the webpage and the URL. The script will prompt for the location and name for the file where you wish to store that information (example output file).
tell application "Safari" set myFile to open for access (choose file name) with write permission set windowNumber to 1 repeat the number of windows times set myTabs to every tab of window windowNumber write "----- Window Number " & windowNumber & " ----- " to myFile set tabNumber to 0 repeat with aTab in myTabs set tabTitle to name of aTab & " " write tabTitle to myFile set tabURL to URL of aTab & " " write tabURL to myFile set tabNumber to tabNumber + 1 end repeat write "Window Number: " & windowNumber & " Number of tabs: " & tabNumber & " " to myFile set windowNumber to windowNumber + 1 end repeat close access myFile end tell
[ More Info ]