Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create a Numbers document listing all Safari bookmarks Apps
You might find this AppleScript interesting and/or useful -- it opens a spreadsheet in Numbers of all of your Safari bookmarks.
set the bookmarks_folderpath to the POSIX path of (path to "cach" from user domain) & "Metadata/Safari/Bookmarks/"

tell application "System Events"
  set these_bookmark_filepaths to the POSIX path of every disk item of folder bookmarks_folderpath whose name extension is "webbookmark"
  -- generate book mark AppleScript list: {{bookmark 1 name, bookmark 1 URL}, {bookmark 1 name, bookmark 1 URL}, etc.}
  set the bookmarks_list to {}
  repeat with i from 1 to the count of these_bookmark_filepaths
    set this_bookmark_path to item i of these_bookmark_filepaths
    tell property list file this_bookmark_path
      set the end of the bookmarks_list to {value of property list item "Name", value of property list item "URL"}
    end tell
  end repeat
end tell

-- convert AppleScript list to text
repeat with i from 1 to the count of the bookmarks_list
  set this_bookmark to item i of the bookmarks_list
  if i is 1 then
    set the bookmark_text to (item 1 of this_bookmark) & tab & (item 2 of this_bookmark)
  else
    set the bookmark_text to the bookmark_text & return & (item 1 of this_bookmark) & tab & (item 2 of this_bookmark)
  end if
end repeat

-- write to file
set the target_file to (path to documents folder as string) & "Safari Bookmarks.cvs"
write_to_file(bookmark_text, target_file, false)

-- open in Numbers
tell application "Numbers"
  activate
  open file target_file
end tell

on write_to_file(this_data, target_file, append_data)
  try
    set the target_file to the target_file as string
    set the open_target_file to open for access file target_file with write permission
    if append_data is false then set eof of the open_target_file to 0
    write this_data to the open_target_file starting at eof
    close access the open_target_file
    return true
  on error
    try
      close access file target_file
    end try
    return false
  end try
end write_to_file
For the AppleScript wizards out there, I didn't send the data directly to Numbers because the Numbers scripting dictionary does not support making a document with the make verb.

[robg adds: I tested this one, and it works as described. Note that it creates a file in your user's Documents folder as an interim step.]
    •    
  • Currently 1.20 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[6,958 views]  

Create a Numbers document listing all Safari bookmarks | 4 comments | Create New Account
Click here to return to the 'Create a Numbers document listing all Safari bookmarks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a Numbers document listing all Safari bookmarks
Authored by: kenji on Jun 15, '09 10:17:11AM

This didn't work for me -- "The document 'Safari Bookmarks.cvs' could not be opened.", Numbers told me.

If I opened the CVS file in TextWrangler, replaced the tabs with commas, and renamed the extension to CSV, then Numbers opened it just fine.



[ Reply to This | # ]
Create a Numbers document listing all Safari bookmarks
Authored by: ChazMacs on Jun 16, '09 09:42:01AM

I'm not an AppleScript user, generally, but tried this. I got an error when running the script in Script Editor:
Syntax Error
Expected class name but found identifier.

The word "disk" was highlighted in the line:
tell application "System Events"
set these_bookmark_filepaths to the POSIX path of every disk item of folder bookmarks_folderpath whose name extension is "webbookmark"

Is it just me, or am I doing something incorrectly?



[ Reply to This | # ]
Create a Numbers document listing all Safari bookmarks
Authored by: Anonymous on Jun 16, '09 12:18:19PM

A list of URLs in an application called "Numbers". How quaint.

It seems the temp file is actually more useful than the intended result.



[ Reply to This | # ]
Create a Numbers document listing all Safari bookmarks
Authored by: halloween on Aug 25, '09 01:41:48PM
i agree with kenji Halloween costume ideas 2009

[ Reply to This | # ]