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.
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.
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.
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
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.
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.
Mar 6, 2018 at 6:23