1

How can I get my Safari bookmarks automatically sorted alphanumerically within Bookmarks manager?

I want to accomplish this without installing a bookmark management tool, nor by going through the process described at this link 1.

  • They make plenty of mistakes. It's almost painful, the contrast between then and now. They used to nail every little thing, every detail. Not now. – chiggsy Feb 4 '18 at 23:06
  • @chiggsy as 'The Verge' put it, "MacOS is becoming legacy Software". Apple fired their OS dev team around the time they released Lion. Strangely and ominously, the death of Steve Jobs coincided with the Beginning of the End of MacOS. – Darf Nader Mar 6 '18 at 4:10
2

You cannot. Safari does not include that functionality.

You can easily achieve sorting using plugins such as SafariSort, but as you write that you do not in want to use any third party tools - you're out of luck.

You should consider using another browser if this functionality is important to you.

  • Drat, figured as much. I loathe Safari but I have to use it because of extension problems with Chrome and Firefox for the stuff I’m working on, and I thought it would be nice if I at least had my bookmarks to keep me company. I’ll just have to wait until I’m done with it. Thanks. – Darf Nader Feb 1 '18 at 11:48
2

This functionality is now available with the most recent OS update, 10.13.4. You are now able to sort either by name or website: https://www.macobserver.com/tips/quick-tip/macos-10-13-4-sorting-safari-bookmarks/

Alas, in introducing this feature, it appears they've removed the ability to sort chronologically. I've sent a complaint to Apple about this.

I should also note that this functionality does not work on my main admin user account, but does work in a fresh admin test account. I don't know if this problem is common, or particular to my user account

-2

You can nearly get there with a bit of Applescript.

This script will read all the "Children" of your existing Bookmarks file and re-write them in the order you specify. "Children" consist first of History, Bookmarks Bar, Bookmarks Menu and Reading List, so you might want to leave the first 4 items in place. After that, specify whatever ordering you like - automatically finding an alphabetic ordering left as an exercise.

set tfile to (path to library folder from user domain as text) & "Safari:BookmarksWorking.plist"

tell application "System Events"
    set childrenOrdered to make new property list item at end of property list items of contents of property list file tfile with properties {kind:list, name:"childrenOrdered"}

    set myOrdering to {1, 2, 3, 4, 6, 5, 7} -- your preferred order
    repeat with i in myOrdering
        set thisChild to (property list item i of property list item "Children" of property list file tfile)
        set thisKind to kind of thisChild
        set thisValue to value of thisChild
        tell childrenOrdered
            make new property list item at end with properties {kind:thisKind, value:thisValue}
        end tell
    end repeat

    -- Instead of overwriting the contents of "Children", this empties the whole file. So do the rename manually for now.
    --set (value of (property list item "Children" of property list file tfile)) to (value of childrenOrdered)
end tell

I expected the last set line of the script to replace the contents of "Children" with the ordered array. Unfortunately this seems to result in an empty (0 byte) file! AppleScript considers the name field read-only, so changing it in place wont work either.

However, manually renaming the items in a property list editor (XCode, text editor, etc.) so that Children is moved aside and orderedChildren is in its place does result in the new ordering appearing in Safari on relaunch.

Pretty clumsy, but if this is heading in the right direction is could be cleaned up and automated.

  • Not only did it not sort alphanumerically as requested, it also deleted all of the bookmarks except for the folders. – user3439894 Mar 5 '18 at 4:35
  • @user3439894 thank you for being the test pilot on the exploding Soviet rocket so I didn't have to. I will be sure to back up my bookmarks before attempting running any version of this script. – Darf Nader Mar 6 '18 at 3:53
  • @heath-raftery thank you for actually attempting to solve what should be a very basic feature of the browser with some AppleScript. I am bemused that while I can program in at least 5 languages, I have never bothered with AppleScript. You've inspired me to give it a try. I am sure there are a zillion things I should be automating. – Darf Nader Mar 6 '18 at 3:53
  • AppleScript is one of those languages that attempts to be awfully conversational, which ends up revealing just how ambiguous conversation is! Sorry for your experience @user3439894 - obviously it was not the script that did this since it doesn't remove things, only adds (see BookmarksWorking.plist and childrenOrdered). There's lots of variations on alphabetical ordering (within folders, including bar items or not, etc.) so there's a few different ways it could go from there. Hopefully future readers will still see that the positive scored answer "You cannot" is not quite right. – Heath Raftery Mar 6 '18 at 6:23
  • Thanks @HeathRaftery, I guess Safari is a lot like Internet Explorer- the OS-included browser that nobody likes for legitimate reasons. Too bad, since Apple banks on it for syncing with iOS devices over iCloud. Disappointing all in all. – Darf Nader Mar 6 '18 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .