I wonder why Safari after so many years still has the worst-in-class bookmark management of any major web browser.
* Poor user interface.
* Poor searching.
* No tags or support for other metadata.
* No shortcuts.
Features that we've taken for granted in other browsers for many years strangely seem to be beneath Apple's notice.
Safari's bookmark system is serviceable for day-to-day stuff, but for managing many hundreds or thousands of bookmarks it's a wash. You just can't find things easily enough, and organizing them is overly tedious.
There are always options like URL Manager Pro, Little Bookmark Box (both of which I own), and other 3rd party bookmark managers, but even though some of these are quite nice they often lack features I want.
Enter Applescript and the Finder.
This script saves a .webloc file referencing the front page in Safari to the folder ~/Documents/Bookmarks_Safari/.
It would be easily possible to create different scripts to save in specific folders such as 'Urgent' or 'Pending', and it would also be easy to provide a pick-list of save locations.
In the Finder you can organize things to your heart's content, and you can tag items using Finder-comments or a metadata-aware utility like TagIt, Leap, PathFinder, etc. Spotlight then gives you many options for searching, and a utility like HoudaSpot makes Spotlight even easier to use in sophisticated fashion.
Enjoy.
------------------------------------------------------------------------------------------------
# Created: 2012-09-22 : 04:34
# Modified: 2012-09-22 : 05:12
# Application: Safari » Finder
# Purpose: Write webloc file in the Finder
# Dependencies: None
------------------------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------------------------
on write_to_file_overwriting(someText, targetFile)
try
set resultNumber to open for access targetFile ¬
with write permission
set eof of resultNumber to 0
write someText to resultNumber
close access resultNumber
on error errMsg number errNum
try
close access resultNumber
on error errMsg number errNum
beep
display dialog "Error: " & errMsg & return & "Error Number: " & errNum
end try
end try
end write_to_file_overwriting
------------------------------------------------------------------------------------------------
--» MAIN
------------------------------------------------------------------------------------------------
try
set bkmksFldr to ("" & (path to documents folder) & "Bookmarks_Safari:")
try
alias bkmksFldr
on error e
do shell script "mkdir " & quoted form of (POSIX path of bkmksFldr)
end try
tell application "Safari"
tell front document
set _name to its name
if length of _name > 50 then
set _name to text 1 thru 50 of _name
end if
# Sanitize file name.
set _name to do shell script "sed -E 's/[:,|/-]/ /g; s/ +/ /g' <<< " & quoted form of _name
set _url to its URL
end tell
end tell
set fName to bkmksFldr & _name & ".webloc"
set webLocTmplt to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<plist version=\"1.0\">
<dict>
<key>URL</key>
<string>" & _url & "</string>
</dict>
</plist>
"
write_to_file_overwriting(webLocTmplt, fName)
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
------------------------------------------------------------------------------------------------