applescript or automator to export safari bookmarks
Thanks.
MacBook Pro i7 2.66GHz, Mac OS X (10.6.5)
MacBook Pro i7 2.66GHz, Mac OS X (10.6.5)
c_kyr wrote:
Can I use applescript or automator to export safari bookmarks? I would like to periodically save an html copy of my bookmarks. Is it possible?
c_kyr wrote:
Can I use applescript or automator to export safari bookmarks? I would like to periodically save an html copy of my bookmarks. Is it possible?
*tell application "Safari" to activate*
*tell application "System Events" to tell process "Safari"*
* click menu item "Export Bookmarks…" of menu 1 of menu bar item "File" of menu bar 1*
* keystroke "d" using command down* -- to save on the desktop
* click button "Save" of window 1*
* if sheet 1 of window 1 exists then click button "Replace" of sheet 1 of window 1*
*end tell*
set myHTML to cjmSafariBookmarkHTML()
on cjmSafariBookmarkHTML()
set urlListText to "<html><body>" & return & "<h1>Safari Bookmarks - " & (short date string of (current date)) & "</h1>" & return
set theDBPath to (POSIX path of (((path to current user folder) as string) & "Library:Safari:Bookmarks.plist"))
tell application "System Events"
try
set myBundle to value of property list items of property list file theDBPath
repeat with mySet in (item 2 of myBundle)
try
if (|Children| of mySet) is not equal to {} then
set urlListText to urlListText & "<h2>" & (|Title| of mySet) & "</h2>" & return
set urlListText to urlListText & "<ul>" & return
repeat with myDict in (|Children| of mySet)
set urlListText to urlListText & "<li><a href=\"" & (URLString of myDict) & "\">" & (|title| of URIDictionary of myDict) & "</a></li>" & return
end repeat
set urlListText to urlListText & "<ul>" & return
end if
end try
end repeat
on error theErr
activate
display dialog theErr
end try
end tell
set urlListText to urlListText & "</body></html>"
return urlListText
end cjmSafariBookmarkHTML
applescript or automator to export safari bookmarks