Inspired by the script that exports a list of your current Google Chrome Tabs to Evernote, reader Francesco Di Lorenzo made a modification that saved the list to a Text file instead. I thought that this was a great idea, so I made a few tweaks and thought I’d publish a version here which does […]

(*
Veritrope.com
Export All Safari Tabs to a Text File
VERSION 1.01
March 5, 2013

// 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-safari-tabs-to-a-text-file

// REQUIREMENTS
     More details on the script information page.

// CHANGELOG
    1.1  REVISED FILE NAMING METHOD
    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 : "URL List from Safari 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

-- GET TABS FROM SAFARI
tell application "Safari"
    activate
    set safariWindow to window 1
    repeat with w in safariWindow
        try
            repeat with t in (tabs of w)
                set TabTitle to (name 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 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 report_Title default location (path to desktop folder)
end tell

--WRITE THE FILE
tell application "System Events"
    set save_File to open for access (save_File & ".txt" as string) with write permission
    try
        write url_list to save_File
    end try
    close access save_File
end tell

Inspired by the script that exports a list of your current Google Chrome Tabs to Evernote, reader Francesco Di Lorenzo made a modification that saved the list to a Text file instead. I thought that this was a great idea, so I made a few tweaks and thought I’d publish my version here (as well […]

(*
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 : "URL List from 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

-- GET TABS FROM CHROME
tell application "Google Chrome"
    activate
    set chromeWindow to window 1
    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 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 report_Title & ¬
        ".txt" default location (path to desktop folder)
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

Originally posted in the Omni Forum, this collaboration between Chris Brogan and Rob Trew is a great example of using AppleScript to automate something that would be a regularly-recurring time-sink to you otherwise! In Chris’s words: ‘Every week I need to produce a weekly report of active projects and completed work. Currently this is quite […]

(*
Veritrope.com
OmniFocus - Weekly Project Report Generator
Authored by Chris Brogan and Rob Trew
Version 1.0
February 5, 2012

// UPDATE NOTICES
     ** Follow @Veritrope on Twitter, Facebook, Google Plus, and ADN for Update Notices! **
     
// SCRIPT INFORMATION AND UPDATE PAGE
    http://veritrope.com/code/omnifocus-weekly-project-report-generator

    Originally Posted At:
    http://cl.ly/1H1M0S3R160x3401150u

// REQUIREMENTS
More details on the script information page.

//CHANGELOG
1.0  Initial Release

*)


(*
======================================
// MAIN PROGRAM
======================================
*)


tell application "OmniFocus"
   
    --SET THE REPORT TITLE
    set ExportList to "Current List of Active Projects" & return & "---" & return & (current date) & return & return as Unicode text
   
    --PROCESS THE PROJECTS
    tell default document
        set refFolders to a reference to (flattened folders where hidden is false)
        repeat with idFolder in (id of refFolders) as list
            set oFolder to folder id idFolder
            set ExportList to ExportList & my IndentAndProjects(oFolder) & return
        end repeat
       
        --ASSEMBLE THE COMPLETED TASK LIST
        set ExportList to ExportList & return & return & "Completed Tasks From Last 7 days" & return & "---" & return & return & "<span style='font-size:8pt'>"
        set week_ago to (current date) - 7 * days
        set refDoneInLastWeek to a reference to (flattened tasks where (completion date ≥ week_ago))
        set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of refDoneInLastWeek
        set strText to ""
        repeat with iTask from 1 to length of lstName
            set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
            if varDate is not missing value then set strText to strText & short date string of varDate & " - "
            if varProject is not missing value then set strText to strText & " [" & varProject & "] - "
            set strText to strText & strName
            if varContext is not missing value then set strText to strText & " *@" & varContext & "*"
            set strText to strText & "  " & return
        end repeat
    end tell
   
    set ExportList to ExportList & strText & "</span>" as Unicode text
   
    --CHOOSE FILE NAME FOR EXPORT AND SAVE AS MARKDOWN
    set fn to choose file name with prompt "Name this file" default name "Weekly Development Report" & ¬
        ".md" default location (path to desktop folder)
    tell application "System Events"
        set fid to open for access fn with write permission
        write ExportList to fid
        close access fid
    end tell
end tell

(*
======================================
// MAIN HANDLER SUBROUTINES
======================================
*)


on IndentAndProjects(oFolder)
    tell application id "OFOC"
        set show_section to false
        set strIndent to "##"
        set oParent to container of oFolder
        repeat while class of oParent is folder
            set strIndent to strIndent & "#"
            set oParent to container of oParent
            set show_section to true
        end repeat
       
        set {dlm, my text item delimiters} to {my text item delimiters, return & return}
        set dteNow to (current date)
        set strActive to (name of (projects of oFolder where its status is active and it is not singleton action holder and its defer date is missing value or defer date < dteNow)) as string
       
        set my text item delimiters to dlm
       
        return strIndent & name of oFolder & return & strActive & return
    end tell
end IndentAndProjects