Last active
August 29, 2015 14:24
-
-
Save tom-henderson/f7b07bbfe607c7f024fd to your computer and use it in GitHub Desktop.
Export Chrome windows to text
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
(* | |
◸ Veritrope.com | |
Export All Chrome Tabs to a Text File | |
VERSION 1.0 | |
September 8, 2012 | |
// INSPIRED BY: | |
Francesco Di Lorenzo (@frankdilo) | |
// UPDATE NOTICES | |
** Follow @Veritrope on Twitter, Facebook, Google Plus, and ADN for Update Notices! ** | |
// SUPPORT VERITROPE! | |
If this AppleScript was useful to you, please take a second to show your love here: | |
http://veritrope.com/support | |
// SCRIPT INFORMATION AND UPDATE PAGE | |
http://veritrope.com/code/export-all-chrome-tabs-to-a-text-file | |
// REQUIREMENTS | |
More details on the script information page. | |
// CHANGELOG | |
1.0 INITIAL RELEASE | |
// TERMS OF USE: | |
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. | |
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. | |
*) | |
(* | |
====================================== | |
// USER SWITCHES (YOU CAN CHANGE THESE!) | |
====================================== | |
*) | |
-- NAME OF REPORT TITLE | |
property report_Title : "Chrome Tabs" | |
(* | |
====================================== | |
// MAIN PROGRAM | |
====================================== | |
*) | |
-- PREPARE THE LIST | |
set url_list to {} | |
set the date_stamp to ((the current date) as string) | |
set NoteTitle to report_Title & " | " & the date_stamp | |
set file_name to report_Title & " " & (do shell script "date '+%F %H-%M'") | |
set default_location to "/Users/tom/Dropbox/Chrome Tabs/" | |
-- GET TABS FROM CHROME | |
tell application "Google Chrome" | |
activate | |
set numWindows to count of windows | |
repeat with windowNumber from 1 to numWindows | |
set chromeWindow to window windowNumber | |
repeat with w in chromeWindow | |
try | |
repeat with t in (tabs of w) | |
set TabTitle to (title of t) | |
set TabURL to (URL of t) | |
set TabInfo to ("" & TabTitle & return & TabURL & return & return) | |
copy TabInfo to the end of url_list | |
end repeat | |
end try | |
end repeat | |
end repeat | |
end tell | |
-- CONVERT URL_LIST TO TEXT | |
set old_delim to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to return | |
set url_list to (NoteTitle & return & return & return & url_list) as text | |
set AppleScript's text item delimiters to old_delim | |
-- CHOOSE FILE NAME FOR EXPORT | |
-- (WRAPPING IN A FINDER FUNCTION SO THE DIALOG WORKS IN ALFRED, KM, ETC.) | |
tell application "Finder" | |
activate | |
set save_File to choose file name with prompt "Name this file:" default name file_name & ".txt" default location (POSIX path of default_location) | |
end tell | |
--WRITE THE FILE | |
tell application "System Events" | |
set save_File to open for access save_File with write permission | |
try | |
write url_list to save_File | |
end try | |
close access save_File | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment