MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Thu, Feb 25, 2016 10:51 pm

Using AppleScript to record the Safari browser windows and tabs

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 ]

[/os/os-x/applescript] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo